Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VisualVM is unable to profile a web application on Eclipse

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.

like image 938
Daniel Newtown Avatar asked Jun 26 '15 04:06

Daniel Newtown


1 Answers

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.
like image 170
wero Avatar answered Oct 18 '22 09:10

wero