Wildfly Maven Plugin - commands seem to have no effect

664 Views Asked by At

I am using the Wildfly Maven Plugin and it is working, in that it turns on, runs web application, however I am having trouble with my custom configurations, namely:

  • Setting the Root logger and Console logger to debug mode
  • Allowing connections from 0.0.0.0:8080 or something other than localhost.

Here is my set up:

<plugin>
    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-maven-plugin</artifactId>
    <version>2.0.2.Final</version>
    <executions>
        <execution>
            <phase>install</phase>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <java-opts>
            <java-opt>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044</java-opt>
        </java-opts>
        <commands>
            <!-- **These are the commands that aren't going through** -->
            <command>/subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="DEBUG") </command>
            <command>/subsystem=logging/console-handler=CONSOLE:write-attribute(name="level", value="DEBUG")</command>
            <command>/subsystem=logging/file-handler=debug:add(level=DEBUG,autoflush=true,file={"relative-to"=>"jboss.server.log.dir", "path"=>"debug.log"})</command>
            <command>/subsystem=logging/logger=org.jboss.as:add(level=DEBUG,handlers=[debug])</command>
            <command>/subsystem-----Enable Remote access here?</command>
        </commands>
        <add-user>
            <users>
                <user>
                    <username>admin</username>
                    <password>admin.1234</password>
                </user>
                <user>
                    <username>admin-user</username>
                    <password>user.1234</password>
                    <groups>
                        <group>admin</group>
                        <group>user</group>
                    </groups>
                    <application-user>true</application-user>
                </user>
                <user>
                    <username>default-user</username>
                    <password>user.1234</password>
                    <groups>
                        <group>user</group>
                    </groups>
                    <application-user>true</application-user>
                </user>
            </users>
        </add-user>
    </configuration>
</plugin>

I know when starting from terminal, one would use this: ./standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0 However I am running demos straight from Maven and need to access my webapp from a separate machine.

Note - from within the Wildfly Management page, I can manually set the Root Logger and Console Logger to debug mode and then the proper debug logs will flow out.

For example, manually I could go here: http://127.0.0.1:9990/console/index.html#logging-configuration and then manually change the logging from the default INFO level to DEBUG:

Image of changing logging level manually

So my question is, along with allowing remote access, is how to change the logging level as a command into the maven wildfly plugin.

1

There are 1 best solutions below

4
On BEST ANSWER

You'd need to upgrade the plugin version to 2.1.0.Beta1 to get that to work. The 2.0.x versions do no have the ability to execute CLI commands from the run or deploy goals.

If you need to stick with the version you're using you'd need to define the execute-commands goal. Then you could use the embedded server to configure the server.

<commands>
    <!-- **These are the commands that aren't going through** -->
    <command>embed-server</command>
    <command>/subsystem=logging/root-logger=ROOT:write-attribute(name="level", value="DEBUG") </command>
    <command>/subsystem=logging/console-handler=CONSOLE:write-attribute(name="level", value="DEBUG")</command>
    <command>/subsystem=logging/file-handler=debug:add(level=DEBUG,autoflush=true,file={"relative-to"=>"jboss.server.log.dir", "path"=>"debug.log"})</command>
    <command>/subsystem=logging/logger=org.jboss.as:add(level=DEBUG,handlers=[debug])</command>
    <command>/subsystem-----Enable Remote access here?</command>
    <command>stop-embedded-server</command>
</commands>