11

Please help me with the below exceptions that I obtain while trying to deploy a WAR file on Tomcat server.

07:46:50,076  WARN HostConfig:606 - Exception while expanding web application archive chapal.war
07:47:00,123  INFO StandardHostDeployer:435 - Processing Context configuration file URL file:/home/eqdev/eqgen117/chrad/chapal-puru/tomcat/conf/Catalina/local
host/chapal.xml
07:47:00,158 ERROR Digester:1275 - Begin event threw exception
java.util.zip.ZipException: error in opening zip file
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:203)
        at java.util.jar.JarFile.<init>(JarFile.java:132)
        at java.util.jar.JarFile.<init>(JarFile.java:70)
        at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:56)
        at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:41)
        at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:68)
        at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:102)
        at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:69)
        at org.apache.catalina.startup.ExpandWar.expand(ExpandWar.java:155)
        at org.apache.catalina.startup.SetDocBaseRule.begin(SetDocBaseRule.java:138)
        at org.apache.commons.digester.Digester.startElement(Digester.java:1273)
        at org.apache.catalina.util.CatalinaDigester.startElement(CatalinaDigester.java:65)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentScannerImpl$ContentDispatcher.scanRootElementHook(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
        at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.commons.digester.Digester.parse(Digester.java:1567)
        at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:488)
        at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:482)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
        at org.apache.catalina.startup.HostConfig.checkContextLastModified(HostConfig.java:834)
        at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1070)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:327)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.StandardHost.backgroundProcess(StandardHost.java:800)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1619)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1628)
        at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1608)
        at java.lang.Thread.run(Thread.java:595)
07:47:00,165 ERROR HostConfig:484 - Error deploying configuration descriptor chapal.xml
java.io.IOException: java.util.zip.ZipException: error in opening zip file
        at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:494)
        at org.apache.catalina.core.StandardHost.install(StandardHost.java:863)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:482)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
Pradeep
  • 3,258
  • 1
  • 23
  • 36
Chapax
  • 171
  • 2
  • 2
  • 7
  • Looks quite similar to this one: http://stackoverflow.com/questions/5493931/java-lang-illegalargumentexception-invalid-or-unreadable-war-file-error-in-op – manuna Aug 26 '14 at 13:07

10 Answers10

13

I see this problem when auto-deploy is set to true and I am uploading the war file over a slow connection to a Linux server. For some reason, Tomcat attempts to deploy the WAR before it has finished uploading to the server. Turning off auto-deploy and doing it manually, or ftping the file to a directory on the server other then webapps and then moving it into webapps fixes the problem.

Seems to be a problem with Tomcat not waiting until the file is finished being uploaded before trying to expand it.

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
JReader
  • 320
  • 2
  • 9
5

If you are deploying on Linux then make sure it is readable by the user that the tomcat process is running as. Run "chmod +r" to the war file to add read rights to everyone.

Mike Pone
  • 18,705
  • 13
  • 53
  • 68
  • 3
    Awesome. This just helped me fix my issue after hours of head scratching. Too bad the tomcat errors aren't more helpful! – threejeez Jul 23 '12 at 01:09
  • 1
    @Coral: It's a bit difficult to accept an answer to a question I didn't ask. Additionally, while this answer did help me solve that issue (thanks again, @Mike!), I've since gotten this exception a number of times since then where the issue was not permissions. This exception is general and can be thrown for *any* number of reasons when exploding the war: permissions, corrupt zip, no disk space, etc. Figured I'd throw that in the mix! – threejeez Aug 03 '12 at 15:06
3

I too had the same issue. Changing the permission of the war file solved it

Alessandro Minoccheri
  • 35,521
  • 22
  • 122
  • 171
Vishwanath
  • 31
  • 1
3

Did you FTP the file from Windows to Unix in ASCII mode instead of Binary?

That could be one cause of the file getting corrupted. you might be able to open with ZIP on windows - but try

jar tvf <filename> on Unix to see if it views content correctly

JoseK
  • 31,141
  • 14
  • 104
  • 131
1

I had the same problem and I just unzipped and zipped it again manually. That worked for me.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
sio4
  • 413
  • 1
  • 5
  • 15
1

It looks like your war-file may be corrupted or have the wrong permissions. .war files are zipfiles - can you open one with zip/winzip/7zip or the like and confirm that it is complete and readable? What are the file permissions?

relet
  • 6,819
  • 2
  • 33
  • 41
0

I just had this same problem. I need to burn the WAR file to DVD and copy it to the DMZ. Unfortunately, finalizing the disc in Roxio was corrupting the WAR file for some reason. I stopped finalizing the disc and the WAR deployed normally.

djm
  • 342
  • 3
  • 13
0

I spent a lot of time to understand what can be the reason. Finally, for me it helps when I build the WAR and at the same time local tomcat is down. Otherwise I will see this error. Not sure why but something is preventing to build the proper WAR if local tomcat is UP (via IDE, not standalone). Reason can be IDE. Hope it helps to somebody.

Denys
  • 1,308
  • 12
  • 13
0

I encountered this problem while changing my Tomcat deployment script. It turned out that somebody had been messing around with JAR files in the JDK folder and Tomcat wasn't able to unzip these messed up files.

Word of obvious advice: pay attention to the JAR file names and determine whether or not they're actually legitimate.

Hope that helps.

entpnerd
  • 10,049
  • 8
  • 47
  • 68
0

I was also getting this error. I copied a ~.m2/repository folder from my colleague and it solved my problem.

Ajay
  • 570
  • 8
  • 17