I was now trying to startup a wildfly server instances using the maven plugin, as opposed to the JBOSS_HOME/bin/standalone.bat
Looking at the plugin documentation, I fail to see how one would be able to influence the base dir for the server.
To illustrate the point, here is a working command line example using the stand alone bat.
standalone.bat --server-config=standalone-empty.xml -Djboss.server.base.dir=C:\dev\Widlfly10\wildfly-10.0.0.Final\standalone-cli
On the other hand, if we try to use the maven-plugin, he seems to always be hunting for the configugration file in the default "standalone" folder.
The following is an illustration of a possible start server command attempt.
mvn org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Final:start -Dwildfly.server.type=STANDALONE -Djboss-as.home=C:\dev\Widlfly10\wildfly-10.0.0.Final -Djboss.server.base.dir=C:\dev\Widlfly10\wildfly-10.0.0.Final\standalone-cli -Dwildfly.serverConfig=standalone-empty.xml
And the following of an illustrations of what ends up happening as you trigger this command.
[INFO] --- wildfly-maven-plugin:1.1.0.Final:start (default-cli) @ wildfly-maven-plugin-runner --- Jun 20, 2017 3:31:03 PM org.xnio.Xnio INFO: XNIO version 3.3.1.Final Jun 20, 2017 3:31:03 PM org.xnio.nio.NioXnio INFO: XNIO NIO Implementation Version 3.3.1.Final Jun 20, 2017 3:31:03 PM org.jboss.remoting3.EndpointImpl INFO: JBoss Remoting version 4.0.9.Final [INFO] JAVA_HOME=c:\PROGRA~1\Java\JDK18~1.0_1\jre [INFO] JBOSS_HOME=C:\dev\Widlfly10\wildfly-10.0.0.Final
[INFO] STANDALONE server is starting up. 15:31:06,758 INFO [org.jboss.modules] (main) JBoss Modules version 1.5.1.Final java.lang.IllegalStateException: WFLYCTL0214: Could not get main file: standalone-empty.xml. Specified files must be relative to the configuration dir: C:\dev\Widlfly10\wildfly-10. 0.0.Final\standalone\configuration at org.jboss.as.controller.persistence.ConfigurationFile.determineMainFile(ConfigurationFile.java:311) at org.jboss.as.controller.persistence.ConfigurationFile.(ConfigurationFile.java:172) at org.jboss.as.server.ServerEnvironment.(ServerEnvironment.java:456) at org.jboss.as.server.Main.determineEnvironment(Main.java:297) at org.jboss.as.server.Main.main(Main.java:94) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.jboss.modules.Module.run(Module.java:329)
The above exception clearly illustrates that he wants to find the configuration file in the folder: C:\dev\Widlfly10\wildfly-10. 0.0.Final\standalone\configuration
And this I do not want to happen. Multiple stand alone domains exists, with their independent log folders.
Is there a way that through other configuration properties of the plugin such as "serverArgs" that one can work-around this?
Or is this a plugin limitation?
The documentation for the plugin can be found at. https://docs.jboss.org/wildfly/plugins/maven/latest/run-mojo.html
Looks like the maven plugin is in fact bugy. It is possible to startup the server with the following comman:
mvn org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Final:start -Dwildfly.server.type=STANDALONE -Djboss-as.home=C:\dev\Widlfly10\wildfly-10.0.0.Final -Dwildfly.serverArgs="-Djboss.server.base.dir=C:/dev/Widlfly10/wildfly-10.0.0.Final/standalone-cli" -Dwildfly.serverConfig=../../standalone-cli/configuration/standalone-empty.xml
But when we look at the jvm properties we see the application is run by the plugin with the following commad:
C:\dev\Widlfly10\wildfly-10.0.0.Final\modules org.jboss.as.standalone -Djboss.home.dir=C:\dev\Widlfly10\wildfly-10.0.0.Final -Djboss.server.base.dir=C:\dev\Widlfly10\wildfly-10.0.0.Final\standalone -Djboss.server.log.dir=C:\dev\Widlfly10\wildfly-10.0.0.Final\standalone\log -Djboss.server.config.dir=C:\dev\Widlfly10\wildfly-10.0.0.Final\standalone\configuration -c=standalone-empty.xml -Djboss.server.base.dir=standalone-cli
The interesting thing is that if make the path to the base dir invalid. Say I name the base dir LALALALLALA. E.g.
mvn org.wildfly.plugins:wildfly-maven-plugin:1.1.0.Final:start -Dwildfly.server.type=STANDALONE -Djboss-as.home=C:\dev\Widlfly10\wildfly-10.0.0.Final -Dwildfly.serverArgs="-Djboss.server.base.dir=LALLALALLA" -Dwildfly.serverConfig=standalone-empty.xml
Well then we have the following error that makes a lot of sense: [INFO] STANDALONE server is starting up.
2017-06-20 17:24:30,417 INFO [org.jboss.modules] (thread: main) JBoss Modules version 1.5.1.Final java.lang.IllegalStateException: WFLYSRV0122: Server base directory does not exist: LALLALALLA at org.jboss.as.server.ServerEnvironment.(ServerEnvironment.java:430) at org.jboss.as.server.Main.determineEnvironment(Main.java:297) at org.jboss.as.server.Main.main(Main.java:94) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
So it would appear that one way or another the base.dir property does play a role. But ultimately when the folder for the base dir is valid, the folder that ends up getting used is always the standalone folder not the one specified via call to the maven plugin.
The artificial pom.xml that is being used to call upon the plugin looks as follows:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.artificialpom</groupId>
<artifactId>wildfly-maven-plugin-runner</artifactId>
<packaging>pom</packaging>
<version>0.0.0-SNAPSHOT</version>
<name>Wildfly Server Maven Plugin</name>
<url>http://maven.apache.org</url>
<dependencies>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.2.0.Alpha5</version>
<configuration>
<server-args>
<server-arg>-Djboss.server.base.dir=C:\dev\Widlfly10\wildfly-10.0.0.Final\standalone-cli</server-arg>
</server-args>
</configuration>
</plugin>
</plugins>
</build>
</project>