VisualVM is unable to profile a web application on Eclipse

3.3k views Asked by At

I would like to profile my Spring Web Application that is running on Tomcat and Eclipse. I added VisualVM to the Eclipse and followed below steps to run the application for profiling.

Right click on the application name > 
Run As > 
Run Configuration > 
Java Application > 
'Selected Project' > 
Set 'org.apache.catalina.starup.Boostrap' as a value for Main class, 
also selected VisualVM as the Launcher > clicked on Run button.

The VisualVM starts but shows following message:

  "Cannot open requested application"

Under local I can see VisualVM, Eclipse and Tomcat.

Following exception will be thrown and shown on console as well:

 Exception in thread "main" java.lang.NoClassDefFoundError: 
org/apache/juli/logging/LogFactory
    at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:59)
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more

I reckon the issue is because of wrong server selected. Maybe I should choose Tomcat but not sure how.

3

There are 3 answers

0
wero On

Probably an issue with an incomplete classpath when the VisualVM plugin launches Tomcat. You could try to correct the classpath of the start configuration which you created (e.g. try to add bin/tomcat-juli.jar from your tomcat installation) but I doubt this will work easily.

You can try the following:

  • start your Tomcat, e.g. from Eclipse
  • then manually start VisualVM: It is actually part of the JDK and located in <JDK dir>/bin/jvisualvm(.exe)
  • in the application list you should see the Tomcat process and then you can open it with a double click.
0
Costlow On

Try using Java Mission Control by running jmc. It is included in recent versions of the JDK. See the getting started doc at http://docs.oracle.com/javacomponents/jmc-5-5/jmc-user-guide/index.html

Run your application, then open the jmc window and connect to the Tomcat process.

0
Loganathan Mohanraj On

This is caused when a class file that your code depends on is not found at run time. This is purely an issue with the class path. Either the class is not exists in the class path or you have a different version of JAR file in the class path. The exception will go away if the class path is corrected.