My project build tool is Maven, so solution is straight: use jboss-as-maven-plugin. I want to generate war file from maven and deploy it to standalone JBoss without restarting it.
Steps to follow
- Define plugin in pom.xml. The definition below attaches to "clean" and "package" maven life cycles.
<build>
...
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>7.1.1.Final</version>
<configuration>
<filename>${project.build.finalName}.war</filename>
</configuration>
<executions>
<execution>
<id>undeploy</id>
<phase>clean</phase>
<goals>
<goal>undeploy</goal>
</goals>
<configuration> <ignoreMissingDeployment>
true
</ignoreMissingDeployment>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
...
</buiid>
</project>
- Optionally - create Eclipse launch configuration to execute "mvn package" or "mvn clean package".
- Start JBoss, run launch configuration in Eclispe, check messages in your server log that new context is regustered and war file is deployed / replaced.
What happens behind the scenes?
Usually deployed war files placed in <jboss7>/standalone/deployments folder (when standalone configuration used). After JBoss restart the war file gets deployed (new "xxxx.deployed" flag file gets created in the same folder).In case of "jboss-as-maven-plugin" deployment, the <jboss7>/standalone/configuration/standalone.xml file gets modified: a new "<deployment>...</deployment>" added to it.
The actual deployed war file can be found now under one of the <jboss7>/standalone/data/content/ subfolders.
Hi Andriy,
ReplyDeleteThanks for posting this. I have been searching for the exploded WAR although my WAR is deployed and I see an entry for this in standalone.xml. But in /standalone/data/content/subfolders, I just see a large encrypted file. Is JBoss encrypting the whole WAR to a file? Please correct me if I am wrong. Thanks.
JBoss does not encrypt the whole file, only changes the deployment name to some unique value. You still can rename it back and use if necessary (unzip, redeploy, etc.)
ReplyDelete