6

I have apache tomcat 7 running on local and a web application deployed as .war file to this server. I am trying to use visualvm to profile the application but so far I am only able to profile tomcat itself.

I am able to see everything about tomcat in the interface and there are absolutely no problems. I am able to see indvidiual tomcat functions as well which are of no meaning to me.

What I want to see is the execution time of the functions of my deployed web application, in other words my own code. But I am unable to do that? Has anyone ever managed to do this profiling? Do I need to set a JMX connections or something with my deployed application? Below you can find my screen which I am able to profile tomcat functions.

My VisualVM screen which I am able to profile tomcat

Tomas Hurka
  • 6,723
  • 29
  • 38
ralzaul
  • 4,280
  • 6
  • 32
  • 51

1 Answers1

9

You can filter methods displayed in "profiler". but what you want is "sampler".

Here is what you should do.

Before you run sampler. You must check the "settings" checkbox on right of profiling window.

It will show you settings where you can write what packages should be profiled.

for example:

com.myCompany.module.*

profiler

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
MarekM
  • 1,426
  • 17
  • 14
  • I tried that now and I am still unable to get any results for the functions I want. The thing is, should I be able to see my functions (com.mycompany.. ) while I am connected to local tomcat instance. Or do I need to create a connections straight to my running application to be able to profile it? – ralzaul Mar 11 '15 at 12:54
  • I am assuming your server is on localhost. You should be able to see method executions withoud any additional settings. Try use another tool shipped with java - JMC - java mission control or if you want to try [setup JMX](http://stackoverflow.com/questions/1263991/connecting-remote-tomcat-jmx-instance-using-jconsole) – MarekM Mar 11 '15 at 13:24
  • ok Marek I will try that. Although I set the filters, I am not able to see any actual method executions with this one. When I set the filter it is just blank and VM is not able to match any functions with my filter. – ralzaul Mar 11 '15 at 13:27
  • yep the sample with the filters are working fine. This will be good enough for me, thanks a lot. So if you can just add that to your response that attaching to apache process is just enough for monitoring applications deployed on it, I will select you response as the correct response and hopefully no one would lose half a day for investigating that issue again :) – ralzaul Mar 11 '15 at 13:38