Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

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

m
m
Line 10: Line 10:
 
==Remedy==
 
==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:
+
The remedy is to avoid hot replacing Jar or WAR files, which can be difficult if you are using the [http://wiki.eclipse.org/Jetty/Feature/ContextDeployer hot Context Provider]. You can use the following techniques to reduce exposure to this issue:
  
 
* Deploy unpacked classes in the <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>.

Revision as of 16:31, 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 hot Context Provider. 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 temporary 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 temporary directory is in use.

Back to the top