How to repack an Java Web Archive (WAR)?
Question
I have a .war file of an application. It works, but I need to update some inner jars (only minor version changes)
While I can operate on .war archives using the
midnight commander, the files can't be executed anymore:
java.lang.SecurityException: SHA1 digest error
.
I tried repacking it using the jar command, but I get it wrong: The archive contains new META-INF, and no WEB-INF (which is needed).
Thank you for proposed solutions!
Solution
The names should be META-INF
and WEB-INF
, without an "O".
Are you modifying the jar files in WEB-INF/libs
? Because it sounds like you have tampered with a signed archive, and normally the war itself is unsigned.
If you alter a signed jar file, the signature is invalidated. Either re-sign the code with your code-signing key, or remove the invalidated signature information from the META-INF.