Connect visualvm to java application running in gradle shell

I am trying to connect visualvm to my java application which is built using jetty and gradle. The app runs on localhost, so no remote connections are required. However, whenever I try to connect to my application, I just connect to the gradle wrapper and therefore cannot profile my application with visualvm. Searching here and google was short.

So far I have been trying to add 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 have also tried uncommenting the following from the jetty-jmx.xml file

<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" />                                                                                                                               

      

+3


source to share





All Articles