Wednesday, August 1, 2012

JBoss 7 and Maven Plugin

This days I play a lot with the latest version of JBoss Teiid (8.1.Beta2). As part of my development activity I have JBoss 7.1.1.Final running on my workstation, and I want to shorten my development cycle: modify code -> build war -> deploy. Yes, I know about JRebel, but today I want not to use it.
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.
<project...>
    <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.

2 comments:

  1. Hi Andriy,

    Thanks 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.

    ReplyDelete
  2. 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