Recently I was trying out to monitor a wildfly swarm application and I wondered why the standard java approach to connect via JMX RMI did not work. I was using parameters
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.rmi.port=9010 -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
and I was not able to connect via rmi.
But some articles (http://www.mastertheboss.com/jboss-server/wildfly-8/monitoring-wildfly-using-visualvm and https://dzone.com/articles/remote-jmx-access-wildfly-or) gave hints about the same issue with Jboss or Wildfly, so basically it works the same way. On the other hand, it would have been possible using jolokia, which reports via http endpoint, but it was driving me nuts, why I could’nt get it to work with jdk tools. Even in the wildfly swarm documentation, it is not really described.
Here are the steps, how to connect.
- Check whether you have fraction jmx and or management inside your pom. jmx is mandatory, and management is important to know, because if you do not have it, you will be able to connect on the applications listening port (standard is 8080), otherwise, you can only connect via administration port (standard is 9990).
- Start your application. I realized, that although you are trying to connect from your local to an application running on your local, the connection does not succeed. In any other scenario, for example, if you application is running in your docker host, then you have to configure the swarm to allow connections from remote anyway. When service is not configured to allow remote connections, the following appears in the log:
[org.wildfly.swarm.jmx] (main) JMX not configured for remote access
To allow remote connections, you have to start your app with parameter
or you have to provide this setting in the yaml.
- If you do not have management as fraction, then you will find the following line in the logs
[org.wildfly.swarm.jmx] (main) JMX configured for remote connector: implicitly using standard interface
- When using jconsole or jvisualvm you will need a jboss-client.jar which contains the implementation of the vendors protocol. As mentioned on the other sites, you can easily start jconsole with a script provided in any of the downloads of wildfly application server, which already included the required library.
To start jvisualvm, you need to do it like this:
jvisualvm.exe -cp:a $JBOSS_HOME\bin\client\jboss-client.jar
If you do not want to download the complete server package, you can also use the library itself. Maven coordinates:
<dependency> <groupId>org.wildfly</groupId> <artifactId>wildfly-client-all</artifactId> <version>12.0.0.Final</version> </dependency>
- If you do not have management fraction connect with string
or if you have management fraction included, connect with
- If you are using service:jmx:http-remoting-jmx://localhost:9990 to connect, you will find a warning in the standard out
WARN: The protocol 'http-remoting-jmx' is deprecated, instead you should use 'remote+http'.
So please keep in mind, that the deprecated connection strings mentioned everywhere in the internet, will not work any more in the future.