Jump to: navigation, search

Difference between revisions of "Jetty/Zip Exceptions Reading Jar or War Files"

m (New page: {{Jetty Howto | introduction =Zip Exceptions Reading Jar or WAR Files A Zip exception occurs when Jetty rereads a Jar or WAR file. The JVM maintains a cache of zip file indexes, and does...)
 
m
Line 1: Line 1:
 
{{Jetty Howto
 
{{Jetty Howto
| introduction =Zip Exceptions Reading Jar or WAR Files
+
| introduction =
  
 
A Zip exception occurs when Jetty rereads a Jar or WAR file.
 
A Zip exception occurs when Jetty rereads a Jar or WAR file.
Line 6: Line 6:
 
The JVM maintains a cache of zip file indexes, and does not support hot replacement of zip files. Thus if you redeploy a web application using the same WAR or Jar files, exceptions occur when Jetty rereads the jars.
 
The JVM maintains a cache of zip file indexes, and does not support hot replacement of zip files. Thus if you redeploy a web application using the same WAR or Jar files, exceptions occur when Jetty rereads the jars.
  
See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4774421 for more information.
+
See [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4774421 Oracle Bug 4774421] for more information.
  
 
==Remedy==
 
==Remedy==
Line 12: Line 12:
 
The remedy is to avoid hot replacing Jar or WAR files, which can be difficult if you are using the [/display/JETTY/ContextDeployer hot context deployer]. You can use the following techniques to reduce exposure to this issue:
 
The remedy is to avoid hot replacing Jar or WAR files, which can be difficult if you are using the [/display/JETTY/ContextDeployer hot context deployer]. You can use the following techniques to reduce exposure to this issue:
  
* Deploy unpacked classes in <tt>WEB-INF/classes</tt> directory rather than as a Jar file under <tt>WEB-INF/lib</tt>.
+
* Deploy unpacked classes in the <tt>WEB-INF/classes</tt> directory rather than as a Jar file under <tt>WEB-INF/lib</tt>.
 
* Deploy all WAR and Jar files with a version number in their filename or path. If the code changes, a new version number applies, avoiding the cache problem.
 
* Deploy all WAR and Jar files with a version number in their filename or path. If the code changes, a new version number applies, avoiding the cache problem.
 
* Deploy a packed WAR file with the [http://www.mortbay.org/apidocs/org/mortbay/jetty/webapp/WebAppContext.html#setExtractWAR(boolean) setExtractWAR] option set to true. This causes the WAR to be extracted to a temporary directory and thus to a new location. This technique does not work if a [/display/JETTY/Temporary+Directories work] directory is in use.
 
* Deploy a packed WAR file with the [http://www.mortbay.org/apidocs/org/mortbay/jetty/webapp/WebAppContext.html#setExtractWAR(boolean) setExtractWAR] option set to true. This causes the WAR to be extracted to a temporary directory and thus to a new location. This technique does not work if a [/display/JETTY/Temporary+Directories work] directory is in use.

Revision as of 16:01, 29 March 2012



Introduction

A Zip exception occurs when Jetty rereads a Jar or WAR file.

The JVM maintains a cache of zip file indexes, and does not support hot replacement of zip files. Thus if you redeploy a web application using the same WAR or Jar files, exceptions occur when Jetty rereads the jars.

See Oracle Bug 4774421 for more information.

Remedy

The remedy is to avoid hot replacing Jar or WAR files, which can be difficult if you are using the [/display/JETTY/ContextDeployer hot context deployer]. You can use the following techniques to reduce exposure to this issue:

  • Deploy unpacked classes in the WEB-INF/classes directory rather than as a Jar file under WEB-INF/lib.
  • Deploy all WAR and Jar files with a version number in their filename or path. If the code changes, a new version number applies, avoiding the cache problem.
  • Deploy a packed WAR file with the setExtractWAR option set to true. This causes the WAR to be extracted to a temporary directory and thus to a new location. This technique does not work if a [/display/JETTY/Temporary+Directories work] directory is in use.
  • Deploy an unpacked WAR file with the setCopyWebDir option set to true. This causes the directory to be extracted to a temporary directory and thus to a new location. This technique does not work if a [/display/JETTY/Temporary+Directories work] directory is in use.