Wildfly Maven Plugin does not keep the Wildfly instance running in the background

469 Views Asked by At

I have a continuous build job for a Maven Java Project and I need the built application to be deployed to a WildFly 21 instance at the end of the job, which must be kept up and running.

Since it's a Maven project, I'm planning on using WildFly Maven Plugin. I configured version 3.0.2.Final with Maven 3.6.3 on my POM:

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>3.0.2.Final</version>
    <configuration>
            <jboss-home>${jboss.home}</jboss-home>
            <server-config>${jboss.ser.config}</server-config>
            <properties-file>${jboss.properties.file}</properties-file>
            <server-args>
                <server-arg>jboss.server.base.dir=${jboss.server.base.dir}</server-arg>
            </server-args>
            <java-opts>
                <java-opt>-Xmx2048m -Xms640m -XX:MaxPermSize=256M</java-opt>
            </java-opts>
            <startup-timeout>240</startup-timeout>
            <timeout>240</timeout>
            <protocol>remoting</protocol>
            <force>true</force>
            <filename>${filename}</filename>
            <name>${warfile.name}</name>
            <checkPackaging>false</checkPackaging>
            <hostname>${jboss.hostname}</hostname>
            <port>${jboss.management.port}</port>
    </configuration>

When I do mvn wildfly:start or mvn wildfly:run, the WildFly instance starts Ok, application is available, but when the timeout value is reached, the Maven process exits and the WildFly process receives an OS signal to shutdown, then stopping the instance. What I wanted is the WildFly process to be kept running in the background after Maven exits.

From the plugin documentation, I read "wildfly:start starts the application server and leaves the process running", so I was guessing that at least the start goal would leave the Wildfly instance runing after exit. But that's not what I see. How can I use the plugin in order to start a WildFly instance and keep it running in the background after Maven exits?

Thanks in advance. Cheers!

1

There are 1 best solutions below

2
On

I think the plugin is doing exactly what it should do, as the scope of mvn wildfly:start is Starts a standalone instance of WildFly Application Server. The purpose of this goal is to start a WildFly Application Server for testing during the maven lifecycle. as stated on the homepage of the plugin, so they do mean that this was just for testing, it makes perfect sense that the application server is terminated when the shutdown goal is reached.

So I think for this case, you should have an instance of your application server (wildfly) up and running already, and then you do the continuous job with mvn wildfly:deploy, as you don't want your application server on other environments (like UAT or PROD) to just restart every time you do the deployment.

More detail here : https://docs.jboss.org/wildfly/plugins/maven/latest/