Jump to: navigation, search

Jetty/Zip Exceptions Reading Jar or War Files

< Jetty
Revision as of 14:55, 29 March 2012 by Boulay.intalio.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



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 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.

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 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.