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
java jetty visualvm gradle jvisualvm


source to share


No one has answered this question yet

Check out similar questions:

436
Building and running an application through Gradle and Android Studio is slower than through Eclipse
376
Is it possible to declare a variable in Gradle usable in Java?
330
How to run only one test class on gradle
202
How / when to create Gradle wrapper files?
2
Creating an RMI Connector Client
2
Spark metrics are not showing in VisualVM
1
Java VisualVm makes PID disappear
0
Failed to connect to JMX remotely for PocessBuilder
0
MBean does not appear in jconsole when deployed to WebSphere server
0
Tomcat is not listening on configured JMX port



All Articles
Loading...
X
Show
Funny
Dev
Pics