How to deploy an application on Wildfly/JBoss EAP 7 via the Wildfly Maven Plugin


Octocat Save up to a workweek a year by efficiently managing your coding bookmarks, aka #codingmarks, on www.codingmarks.org. Share your favorites with the community and they will be published weekly on Github. Help us build the programming-resources location - Star


This post shows how to deploy a Java EE application on a WildFly or JBoss EAP 7 via the WildFly Maven Plugin1. You can use this plugin to deploy, undeploy or run your application. The post has two parts:

  • deploy application on local server
  • deploy application on remote server via https

Deploy on local Wildfly

Place the plugin configuration in pom.xml file of the module you want to deploy to JBoss. It can be either a war or ear:

<project>
    ...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.1.0.Final</version>
                <configuration>
                    <hostname>localhost</hostname>
                    <port>9990</port>
                    <username>jboss-local-admin</username>
                    <password>jboss-local-admin-password</password>
                    <jboss-home>local-jboss-home</jboss-home>
                    <name>${project.build.finalName}.${project.packaging}</name>
                </configuration>
                <executions>
                    <!-- Undeploy the application on clean -->
                    <execution>
                        <id>undeploy</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>undeploy</goal>
                        </goals>
                        <configuration>
                            <ignoreMissingDeployment>true</ignoreMissingDeployment>
                        </configuration>
                    </execution>

                    <!-- Deploy the application on install -->
                    <execution>
                        <id>deploy</id>
                        <phase>install</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...
        </plugins>
        ...
    </build>
...
</project>

Note:

  • undeploy - is bound to the clean phase, and it won’t complain if it’s not present
  • deploy - is bound to the install phase
  • if you don’t want the deployment to happen in the installation phase, consider moving it in an upper phase in the the maven build cycle2 (e.g. deploy) or enclose it in a profile; for the latter see the second example below

Deploy on remote Wildfly

<profiles>
    <profile>
        <id>deployRemote</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.wildfly.plugins</groupId>
                    <artifactId>wildfly-maven-plugin</artifactId>
                    <version>1.1.0.Final</version>
                    <configuration>
                        <hostname>remote_host</hostname>
                        <protocol>https-remoting</protocol>
                        <port>9993</port>
                        <username>jboss-admin</username>
                        <password>jboss-admin-password</password>
                        <jboss-home>remote-jboss-home</jboss-home>
                        <name>${project.build.finalName}.${project.packaging}</name>
                    </configuration>
                    <executions>
                        <!-- Undeploy the application on clean -->
                        <execution>
                            <id>undeploy</id>
                            <phase>clean</phase>
                            <goals>
                                <goal>undeploy</goal>
                            </goals>
                            <configuration>
                                <ignoreMissingDeployment>true</ignoreMissingDeployment>
                            </configuration>
                        </execution>

                        <!-- Deploy the application on install -->
                        <execution>
                            <id>deploy</id>
                            <phase>deploy</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

Note:

  • undeploy - is bound to the clean phase, and it won’t complain if it’s not present
  • deploy - is bound now to the deploy phase
  • https is enabled by setting the protocol to https-remoting and the corresponding port 9993
  • the plugin’s operations are now executed only with a specified profile deployRemote; so you’d have to run the build like the following:
shell> mvn clean deploy -PdeployRemote

References

Adrian Matei

Adrian Matei
Life force expressing itself as a coding capable human being

How I save a workweek a year by efficiently managing my codingmarks

Finding a desired link, you already visited, can be a tedious job and sometimes even frustrating. It normally takes 30 seconds or more to look for a link the traditional way, and I do that at least 20 times a day. With codingmarks.org it takes about 10 seconds, so I get a time saving of around 20 * 20 / 60 = 6.66 minutes a day. Over a year's time this translates to around 40+ hours of saved time. Continue reading

New codingmarks published in week 52 of 2018

Published on January 01, 2019