ZIP exceptions reading jar or war files

A ZIP exception is thrown when a jar or war file is accessed.

Detailed Description

The JVM maintains a cache of ZIP file indexes and they do not support hot replacement of
zip files. Thus if a web application is redeployed and the same war or jar files are used
then the cache will cause exceptions when re-reading the jars.

See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4774421

Remedy

The remedy is to avoid hot replacing jar or war files - which can be difficult if using the hot context deployer. The following techniques can be used to reduce exposure to this issue:

  1. Deploy unpacked classes in WEB-INF/classes directory rather than as a jar file under WEB-INF/lib
  2. Deploy all war and jar files with a version number in their filename or path. If the code is changed then a new version number is used and the cache problem avoided.
  3. Deploy a packed war file with the setExtractWAR option set to true. This will cause the WAR to be extracted to a temporary directory and thus to a new location. This technique will not work if a work directory is being used.
  4. Deploy an unpacked war file with the setCopyWebDir option set to true. This will cause the directory to be extracted to a temporary directory and thus to a new location. This technique will not work if a work directory is being used.