{"id":98,"date":"2018-05-04T08:41:16","date_gmt":"2018-05-04T08:41:16","guid":{"rendered":"http:\/\/www.matez.de\/?p=98"},"modified":"2018-05-04T08:41:16","modified_gmt":"2018-05-04T08:41:16","slug":"connecting-from-jconsole-or-visualvm-to-wildfly-swarm-instances","status":"publish","type":"post","link":"https:\/\/www.matez.de\/index.php\/2018\/05\/04\/connecting-from-jconsole-or-visualvm-to-wildfly-swarm-instances\/","title":{"rendered":"Connecting from jconsole or VisualVM to wildfly swarm instances"},"content":{"rendered":"<p>Recently I was trying out to monitor a <a href=\"http:\/\/wildfly-swarm.io\/\">wildfly swarm<\/a> application and I wondered why the standard java approach to connect via JMX RMI did not work.\u00a0I was using parameters<\/p>\n<pre>-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<\/pre>\n<p>and I was not able to connect via rmi.<\/p>\n<p>But some articles (<a href=\"http:\/\/www.mastertheboss.com\/jboss-server\/wildfly-8\/monitoring-wildfly-using-visualvm\">http:\/\/www.mastertheboss.com\/jboss-server\/wildfly-8\/monitoring-wildfly-using-visualvm<\/a> and <a href=\"https:\/\/dzone.com\/articles\/remote-jmx-access-wildfly-or\">https:\/\/dzone.com\/articles\/remote-jmx-access-wildfly-or<\/a>) 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\u2019nt get it to work with jdk tools. Even in the wildfly swarm documentation, it is not really described.<\/p>\n<p>Here are the steps, how to connect.<\/p>\n<ul>\n<li>Check whether you have fraction <em>jmx<\/em> and or <em>management<\/em> inside your pom. <em>jmx<\/em> is mandatory, and <em>management<\/em> 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).<\/li>\n<li>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:<\/li>\n<\/ul>\n<pre>[org.wildfly.swarm.jmx] (main) JMX not configured for remote access<\/pre>\n<p>To allow remote connections, you have to start your app with parameter<\/p>\n<pre>-Dswarm.jmx.remote=true<\/pre>\n<p>or you have to provide this setting in the yaml.<\/p>\n<ul>\n<li>If you do not have <em>management<\/em> as fraction, then you will find the following line in the logs<\/li>\n<\/ul>\n<pre>[org.wildfly.swarm.jmx]\u00a0(main)\u00a0JMX\u00a0configured\u00a0for\u00a0remote\u00a0connector:\u00a0implicitly\u00a0using\u00a0standard\u00a0interface<\/pre>\n<ul>\n<li>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.<\/li>\n<\/ul>\n<pre>$JBOSS_HOME\/bin\/jconsole.sh<\/pre>\n<p>To start jvisualvm, you need to do it like this:<\/p>\n<pre>jvisualvm.exe -cp:a $JBOSS_HOME\\bin\\client\\jboss-client.jar<\/pre>\n<p>If you do not want to download the complete server package, you can also use the library itself. Maven coordinates:<\/p>\n<pre>&lt;dependency&gt;\r\n &lt;groupId&gt;org.wildfly&lt;\/groupId&gt;\r\n &lt;artifactId&gt;wildfly-client-all&lt;\/artifactId&gt;\r\n &lt;version&gt;12.0.0.Final&lt;\/version&gt;\r\n&lt;\/dependency&gt;<\/pre>\n<p>or download link\u00a0<a href=\"https:\/\/repo.maven.apache.org\/maven2\/org\/wildfly\/wildfly-client-all\/12.0.0.Final\/wildfly-client-all-12.0.0.Final.jar\">https:\/\/repo.maven.apache.org\/maven2\/org\/wildfly\/wildfly-client-all\/12.0.0.Final\/wildfly-client-all-12.0.0.Final.jar<\/a><\/p>\n<ul>\n<li>If you do not have <em>management<\/em> fraction connect with string<\/li>\n<\/ul>\n<pre>service:jmx:remote+http:\/\/localhost:8080<\/pre>\n<p>or if you have\u00a0<em>management<\/em> fraction included, connect with<\/p>\n<pre>service:jmx:remote+http:\/\/localhost:9990<\/pre>\n<ul>\n<li>If you are using service:jmx:http-remoting-jmx:\/\/localhost:9990 to connect, you will find a warning in the standard out<\/li>\n<\/ul>\n<pre>WARN: The protocol 'http-remoting-jmx' is deprecated, instead you should use 'remote+http'.<\/pre>\n<p>So please keep in mind, that the deprecated connection strings mentioned everywhere in the internet, will not work any more in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.\u00a0I 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 &hellip; <a href=\"https:\/\/www.matez.de\/index.php\/2018\/05\/04\/connecting-from-jconsole-or-visualvm-to-wildfly-swarm-instances\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Connecting from jconsole or VisualVM to wildfly swarm instances&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[21,19,22,20,18,17],"_links":{"self":[{"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/posts\/98"}],"collection":[{"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":4,"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/posts\/98\/revisions\/102"}],"wp:attachment":[{"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.matez.de\/index.php\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}