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

Unfortunately, the cause and the solution is not that obvious as Buhake Sindi suggests. I've seen this problem several times before in several forums. I've even experienced it myself at least once. Google gives currently over 500 hits on the exact exception message. All remains unanswered. There are however hints that it works in IDE X, but not on IDE Y and that it works on Server X, but not on Server Y. Or that removing or adding something from/to the WAR works (a typical example can be found here). Nobody has however explained the real root cause in depth.

I think that it has something to do with a combination of the JDK/JRE version used and the file size of the WAR. Here are some things you can try:

  • Try to update/align the JDK/JRE version in your IDE and/or appserver environment.
  • Try to add something to the WAR, some random JAR or JSP file or whatever and then rebuild.

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.


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.