java.lang.IllegalArgumentException: Invalid or unreadable WAR file : error in opening zip file

后端 未结 15 2553
眼角桃花
眼角桃花 2020-12-14 03:19


I got this error in Catalina.2011-03-30.log when my display.war file executed on Tomcat. The error is shown below:

Mar 30, 2011 8:01:31 PM org.apac         


        
相关标签:
15条回答
  • 2020-12-14 04:11

    Same problem here. war file can be opened by 7-zip.

    Edit: I figured out why. "Invalid or unreadable WAR file : error in opening zip file" is definitely a confusing error message. The real reason is simply "Tomcat unable to deploy the war because there are some initializing errors". In my case, my War file is missing a few config files which throws out file not found exception. Different Tomcat version seems to report different errors. On 6.0.26, it correctly reports the error. But on 6.0.32, it reports the confusing "Invalid or unreadable WAR file".

    0 讨论(0)
  • 2020-12-14 04:14

    I've encountered the error randomly. I think the cause is quite simple.

    It can happen when you create the WAR file and transfer it into the tomcat directory by a "slow" process. In my case it is a tranfer from a remote machine by scp. The tomcat can notice that the file has changed (modification date, etc.) before the transfer is over. It may then try to deploy the incomplete file. It will encounter a zip error.

    The same can in theory happen if you copy the file from another directory; though the chances are smaller, since the copy is faster.

    To avoid the error altogether, the file should be moved (not copied) from another location on the same disk. Such a move is (I think) atomic.

    While I am developing, having the error occur every once in a while is not a big problem, though; when I encounter it I just restart the transfer.

    0 讨论(0)
  • 2020-12-14 04:15

    Thank you @BalusC. Had same issue. Tried many options. Thought this is because of lib I added to maven without prototype scope and as a result it went to war file as well, corrected, same result. I can open it as a zip and all "looks" good there.

    Tried locally (different tomcat version: 7.0.67 versus 7.0.22 I have the issue with) works good. Then tried with 7.0.22 but on different VM (instance) - works good. I suspect there is something with tomcat or probably conflict with other was files (that is only difference with other VM, all including Java is same).

    The issue is resolved for me using different tomcat instance.

    0 讨论(0)
提交回复
热议问题