7

I'm trying to connect visualvm to my java app which is built run using jetty and gradle. The app is running on localhost, so remote connections aren't required. However, whenever I try to connect to the application, I'm merely connecting to the gradle wrapper, and thus cannot profile my application with visualvm. Searching here and google has come up short.

So far, I've tried adding the following lines to my gradle.build file

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=localhost')

I've also tried uncommenting the following from the jetty-jmx.xml

<Call name="createRegistry" class="java.rmi.registry.LocateRegistry">                                                                                 
<Arg type="java.lang.Integer"><SystemProperty name="jetty.jmxrmiport" default="1099"/></Arg>                                                        
<Call name="sleep" class="java.lang.Thread">                                                                                                        
   <Arg type="java.lang.Integer">1000</Arg>                                                                                                         
</Call>                                                                                                                                             

<New id="ConnectorServer" class="org.eclipse.jetty.jmx.ConnectorServer">                                                                              
<Arg>                                                                                                                                               
  <New class="javax.management.remote.JMXServiceURL">                                                                                               
    <Arg type="java.lang.String">rmi</Arg>                                                                                                          
    <Arg type="java.lang.String" />                                                                                                                 
    <Arg type="java.lang.Integer"><SystemProperty name="jetty.jmxrmiport" default="1099"/></Arg>                                                    
    <Arg type="java.lang.String">/jndi/rmi://<SystemProperty name="jetty.jmxrmihost" default="localhost"/>:<SystemProperty name="jetty.jmxrmiport"default="1099"/>/jmxrmi</Arg>                                                                                                                           
  </New>                                                                                                                                            
</Arg>                                                                                                                                              
<Arg>org.eclipse.jetty.jmx:name=rmiconnectorserver</Arg>                                                                                            
<Call name="start" />                                                                                                                               

Chris
  • 354
  • 3
  • 13
  • What OS are you using? Which local application do you see? VisualVM, gradle and anything else? Maybe jetty is running as different user. – Tomas Hurka Jun 21 '17 at 11:58
  • Did you ever find a solution? I have the same problem running a simple Swing-based app. When launched via Eclipse, VisualVM connects to it fine just. (and it uses all the same options, as far as I can tell.) – Luke Usherwood Jan 10 '18 at 10:04

0 Answers0