ZIP exceptions reading jar or war files
A ZIP exception is thrown when a jar or war file is accessed.
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.
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:
- 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 is changed then a new version number is used and the cache problem avoided.
- 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.
- 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.