27

I have a tomcat instance with the JMXRemote parameter configured. The local VisualVM is able to get a sampler on CPU, however, not for Memory. The memory button is grayed out with a summary saying: "Memory sampling: Not available. Cannot connect to target application. Make sure the application is running on a supported JDK 6 or JDK 7"

JMXRemote parameter:

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9086
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

Tomcat JDK version:

JDK1.6.0.30

VisualVM version:

Version: 1.6.0_30 (Build 1320-110325); platform 110131-9c8b3bfb3a1e
System: Windows Server 2008 R2 (6.1) , amd64 64bit
Java: 1.6.0_30; Java HotSpot(TM) 64-Bit Server VM (20.5-b03, mixed mode)
Vendor: Sun Microsystems Inc., http://java.sun.com/
Environment: Cp1252; en_US (visualvm)
Userdir: C:\Users\Administrator\AppData\Roaming\.visualvm\7
Clusters: C:\Program Files\Java\jdk1.6.0_30\lib\visualvm\platform
C:\Program Files\Java\jdk1.6.0_30\lib\visualvm\visualvm
C:\Program Files\Java\jdk1.6.0_30\lib\visualvm\profiler

Tomcat version:

Tomcat 6.0.32

I am running both the VisualVM and Tomcat at win server 2008. Anything i did wrong?

Nathan Hughes
  • 85,411
  • 19
  • 161
  • 250
Reusable
  • 1,718
  • 6
  • 25
  • 43

10 Answers10

9

I had the same problem before. You must have downloaded the version from jvisualvm homepage, right? Don't do it! If you use new jdk 1.7, VisualVM is already packaged in your jdk folder. Use this version, you will not have any problem with memory sample.

Sifeng
  • 689
  • 9
  • 22
  • 1
    That did the trick for me. If using jdk 1.7 visualvm is already part of the jdk in bin/. This made memory sampling work. – mwhs Dec 08 '14 at 16:17
5

This blog post leads me to believe that the temp directories of JVisualVM and Tomcat need to be the same for memory sampling to work. One of the comments on the post:

the temp directory must be set to the one used by JVisualVM, which can be discovered from the VisualVM system properties tab (java.io.tmpdir). Once I set the CATALINA_TMPDIR directory properly, this worked beautifully.

David Minor
  • 612
  • 7
  • 14
  • I believe only CPU sampling can be done remotely. For memory sampling you might try running visualvm on the remote machine and using X11 forwarding to view it, if that's a possibility. – David Minor Oct 23 '12 at 17:48
  • I tried aligning the temp directories for the Tomcat Windows service and visualvm to both be C:\Windows\Temp but I'm still getting the message "Not supported for this JVM" in the visualvm views. – Christian K. Sep 16 '13 at 13:53
2

I've just run into this same issue and the answers above solved my problem but it took me a while to figure out how. Just in case anyone else is still having trouble and ends up this far down the thread, I was using the JDK that is part of the weblogic server configured through Eclipse and not the JDK that I installed seperately. I'm still a junior programmer and I wasn't putting 2 and 2 together until I started looking through my eclipse settings and verified my Installed JREs.

Ran the jvisualvm.exe from the weblogic jdk and all worked.

Alex Riccio
  • 35
  • 12
  • You can also specify which JDK to use with a command like this: `visualvm --jdkhome "C:\Program Files\Java\jdk-11.0.2"` – Matt Sgarlata Jul 22 '19 at 15:36
1

I would check the version of VisualVM is exactly the same as the JVM.

VisualVM is very version specific. I assume its still under fairly rapid development.

(Re posted as an answer as it may be the solution)

Peter Lawrey
  • 498,481
  • 72
  • 700
  • 1,075
0

Here is my solution for similar problem: https://stackoverflow.com/a/16330238/715483

You can resolved this error by

$ ssh -Y user@remotemachine

$ wget http://java.net/projects/visualvm/downloads/download/release135/visualvm_135.zip

$ unzip visualvm_135.zip

$ cd visualvm_135/bin

$ ./visualvm

This instance of visualvm will be full featured, including memory and CPU sampling.

Read more about it here: http://shahriarinia.blogspot.com/2013/05/java-cpumemory-heap-usage-monitoring.html

http://mshahriarinia.com/

Community
  • 1
  • 1
Morteza Shahriari Nia
  • 1,202
  • 17
  • 22
0

Make sure your VirtualVM/JDK is a 32-bit copy if your JRE is. If you are using Eclipse, check the selected JRE on Installed JRE's section.

Sajal Dutta
  • 7,258
  • 25
  • 33
0

And I have the same problem.

I always launched tomcat as a service and connected it with visualvm through jmx connection.

When had corrected catalina.bat:

    set JAVA_OPTS=%JAVA_OPTS% 
    -Dcom.sun.management.jmxremote=true 
    -Dcom.sun.management.jmxremote.port=9090 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Dcom.sun.management.jmxremote.authenticate=false

and launched it with startup.bat, visualvm automatically determine tomcat, and memory sampling was active.

0

I've got the same problem but with different envirnoment. My server was a Linux machine, the client a Windows 7 machine, but the problem is the same.

The solution was to launch the jvisualvm in the same machine and with the same user that is running the targeted application. If i run jvisualvm with other other user (ex: root) the memory button became gray.

0

Firstly, JMX should be enabled. Add the linked command line environment variables necessary to activate JMX if you haven't.

The environment variable CATALINA_TMPDIR should be set to match the JVisualVM as seen in the "System properties" tab of the Local > VisualVM. You can open this by double clicking on the "VisualVM" labeled entry in the Applications pane on the left.

Environment variables can be set by searching for environment, "edit environment variables for your account". New... > Enter a name and value.

enter image description here

If you would like the temporary directory of VisualVM to be somewhere else, you'll have to launch VisualVM from the command line and add an argument.

C:\Program Files\Java\jdk1.8.0_65\bin>jvisualvm.exe -J-Djava.io.tmpdir=C:\Users\You\Temp
Jared
  • 109
  • 2
  • 8
0

I've faced similar issues with JVisualVM, I've even asked a question about it here

A couple of insights/advices:

  1. So, in order to sample memory you don't need jmx options.
  2. I would double check whether you have 64 bit jvms installed along with 32 bit jdks on the same machine (even if they're not running and all the environment vars defined properly), I've read somewhere that sometimes it drives the JVisualVM crazy :) (yes I know it doesn't sound reasonable to us, java developers)

  3. If it doesn't work, just uninstall all jdks that you have and install only 1 that you need. It can solve the issue.

I hope it will help you to resolve the issue, after all like Peter said these things are new and evolving

Community
  • 1
  • 1
Mark Bramnik
  • 31,144
  • 4
  • 41
  • 69
  • 1) if i remove jmx, local shows only 1 item "VisualVM" under the VisualVM application panel 2) there was only 1 JDK 1.6.0_26 and i think the server came together with a JRE6 to began with. i have install the JDK 1.6.0_30 today to see if the new JDK helps. 3) i'll will try that and see what happen – Reusable Jan 10 '12 at 08:33