I have a WAR file. I would like to open it, edit an XML file, remove some jars and then re-package it.
I used WINRAR to open the WAR file and I removed some Jars and did an 'Add to Archive' in WinRar and created a WAR.
When I deployed the WAR in jboss folder, I got an exception.
16:05:14,316 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2)
MSC00001: Failed to start service jboss.deployment.unit."myapplication.war".
STRUCTURE: org.jboss.msc.service.StartException in
service jboss.deployment.unit."myapplication.war".STRUCTURE:
Failed to process phase STRUCTURE of deployment "myapplication.war"
How do I repackage the WAR ?
A WAR file is an archive file, used to group all application files into a convenient package. A WAR file can be created with the jar command, included in the Java runtime environment, or a ZIP utility program such as WinZip .
A war file is just a zip file with a specific directory structure. So you can use unzip or the jar tool for unzipping.
you can update your war from the command line using java commands as mentioned here:
jar -uvf test.war yourclassesdir
Other useful commands:
Command to unzip/explode the war file
jar -xvf test.war
Command to create the war file
jar -cvf test.war yourclassesdir
Eg:
jar -cvf test.war *
jar -cvf test.war WEB-INF META-INF
copy your war file to /tmp now extract the contents:
cp warfile.war /tmp
cd /tmp
unzip warfile.war
cd WEB-INF
nano web.xml (or vim or any editor you want to use)
cd ..
zip -r -u warfile.war WEB-INF
now you have in /tmp/warfile.war your file updated.
This worked for me:
mv xyz.war ./tmp
cd tmp
jar -xvf xyz.war
rm -rf WEB-INF/lib/zookeeper-3.4.10.jar
rm -rf xyz.war
jar -cvf xyz.war *
mv xyz.war ../
cd ..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With