random brain dumps

Configure JBoss for Maven Deployments

8 November 2015

One of the projects I jumped into recently is a hybrid mobile application with a JBoss backend. I’m not very familiar with Java ecosystem, thus setting up a dev environment was a bit of a challenge.

After getting to know WildFly (JBoss AS) I realised I could simply incorporate Maven’s JBoss AS Deployment Plugin, so that any future deployment would be done with an mvn clean package jboss-as:deploy command. That piece of automation looked like something I definitely wanted to have in my toolbox. So far so good, but running this command against my standalone WildFly configured with default settings, was giving me:

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.917 s
[INFO] Finished at: 2015-11-08T05:42:33+01:00
[INFO] Final Memory: 35M/268M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.7.Final:deploy (default-cli) on project ▒▒▒▒▒▒▒▒▒▒▒▒▒: Could not execute goal deploy on /Users/rafek/Dev/▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒/▒▒▒.war. Reason: I/O Error could not execute operation '{
[ERROR] "operation" => "read-attribute",
[ERROR] "address" => [],
[ERROR] "name" => "launch-type"
[ERROR] }': java.net.ConnectException: JBAS012144: Could not connect to remote://localhost:9999. The connection timed out
[ERROR] -> [Help 1]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

That looks partly valid, as jboss-as-maven-plugin’s default configuration is to hit a WildFly instance at localhost:9999. Given that, my thought was, it’s a firewall or a missing binding somewhere. Firewall option was easy to check. Next thing then, was to check a WildFly’s configuration in <path-to-wildlfy>/standalone/configuration/standalone.xml. Under the <socket-binding-group> element, I could find any needed port binding except the 9999 one for native management. It was an easy guess that it’s missing here. Hence the line to add was:

<socket-binding name="management-native" 

And to make above working, the <native-interface> element needs to be defined earlier:

      <native-interface security-realm="ManagementRealm">
        <socket-binding native="management-native"/>

And that’s it. Running the aforementioned Maven command results in success, making the .war file being deplpoyed to the destination:

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.119 s
[INFO] Finished at: 2015-11-08T10:26:31+01:00
[INFO] Final Memory: 35M/374M
[INFO] ------------------------------------------------------------------------

That unlocks for me a wide variety of goals, that are defined in the jboss-as-maven-plugin.

Happy automation!


comments powered by Disqus