JConsole local process list on Windows systems

Several times in the JMX and M&M SDN forums I have seen developers post questions like What should I see in the connection dialog's local process list in JConsole when running on Windows platforms?. There are several answers to this question depending on how both JConsole and the target Java application have been deployed, and more precisely, how the TMP and/or TEMP environment variables have been set in the command shell before launching them.

The following matrix should help you answer the question when JConsole and the target VM are running on JDK 6 or JDK 7:

JConsole/TargetVM matrix for local process list
JConsole ---------->

<---------- Target VM
TMP set to NTFS filesystem1 TMP set to FAT filesystem TMP not set TMP set to non-existing directory
TMP set to NTFS filesystem1 OK2
Java app name
OK2
pid@hostname
KO3 OK2
pid@hostname
TMP set to FAT filesystem KO3 OK2
pid@hostname
KO3 OK2
pid@hostname
TMP not set KO3 OK2
pid@hostname
OK2
Java app name
OK2
pid@hostname
TMP set to non-existing directory KO3 OK2
pid@hostname
KO3 OK2
pid@hostname
  1. NTFS filesystem or any filesystem that supports persistent access control lists.
  2. In the OK cases the output displayed by JConsole in the local process list is:
    • Java app name: the target application's main class name (or jar file if the application was started with the -jar option), or
    • pid@hostname: the process id and the name of the machine where the Java process is running. For example, "1234@oneserver".
  3. In the KO cases you don't see the target VM process in the local process list but you can still connect to it with JConsole by calling jconsole pid where pid can be looked up using the Windows Task Manager application.

NOTE: Sometimes even when both JConsole and the target VM have been started with the TMP and/or TEMP environment variables set to an NTFS filesystem you don't see the Java app name in the local process list. Usually this happens when the output from the jps command is empty and may be due to a file permissions problem. In such situations go to the directory that TMP is defined as and see if there is a directory named hsperfdata_user where user is your login. That is the directory where the instrumentation buffers are mapped (as shared memory files). Each time a java process starts it should create a file in that directory. The file name is the pid and that is how jps and the other jvmstat tools get the process list. If you don't see any pid-like files in the directory then it might be a permission problem. Try to create a file in the directory. If you get an "access denied" error then try to display and modify the ACLs of the directory with the cacls.exe command-line tool. If the problem still persists or you cannot change the ACLs of the directory then a workaround might be to create a new temporary directory in one of the NTFS partitions and just update the TMP variable in your environment to point to it. You can access the environment variables through Control Panel -> System -> Advanced -> Environment Variables.

Comments:

Doesn't the TEMP/TMP environment variables set the java.io.tmpdir system property?

Posted by adobni on July 11, 2007 at 02:53 PM CEST #

Yes, setting TMP/TEMP modifies the value of java.io.tmpdir.

When you set the TMP and TEMP environment variables to a given pathname then the java.io.tmpdir system property will point to the same pathname. However, when both the TMP and TEMP environment variables are unset the java.io.tmpdir system property will point to the "C:\\Documents and Settings\\user\\" directory.

NOTE: TMP always takes precedence on TEMP unless TMP is unset.

Posted by Luis-Miguel Alventosa on July 12, 2007 at 04:10 AM CEST #

Wow this was invaluable, thanks for posting it.

Posted by LK on December 12, 2007 at 07:29 PM CET #

I googled for long time to notice the permission problem for hsperfdata_user.
Suggest to show this kind of error in console, it really can save a lot of efforts for others
>jps
#warning, can't have permission on "hsperfdata_user", please check

Posted by larry cai on January 06, 2008 at 08:07 PM CET #

wow, the hsperfdata_user acl was a shock. My jconsole now displays the local pids just fine. thanks for sharing the info.

Posted by major banzai on January 25, 2008 at 06:21 PM CET #

As mentioned in the first comment of http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6301562 if your windows username has uppercase chars, then it doesn't work.

The solution is to rename %TMP%\\hsperf_MyUser to %TMP%\\hsperf_myuser. And to do the rename you need to quit all java processes.

Posted by David Roussel on September 23, 2008 at 06:48 AM CEST #

Actually, the rule for enabling jps and jconsole is - rename %TMP%\\hsperf_<user> to be exactly equal to your user name (including the case) and remove "Read-only" flag from it.
Windows XP SP 3, JDK 1.5.06

Posted by Dmitry Khalatov on January 04, 2009 at 08:56 AM CET #

This is the SECOND time this page saves me (this time permission problems due to Active Directory upgrade). I deleted the hsperfdata directory and it was recreated with the correct permissions. Thanks again!

Posted by LK on January 22, 2009 at 12:41 PM CET #

Still having the issue... I don't get it, it works on some machines, others it doesn't (win2003 64-bit) - 1.5.0_14_64bit - I checked the above, all is fine... I see the jconsole pid show in the dir, but NONE of the others... all the java processes are started with the
-Dcom.sun.management.jmxremote flag (even windiff'd to check that nothing odd was up)... made sure all env vars match (even used process explorer to compare that internally)... still no dice... ideas?

Posted by Steven May on April 01, 2009 at 05:24 PM CEST #

Located some other items required to get this working (windows/64-bit) ... If using an RDP connection, you MUST used the /console connection to run jconsole under... also, due to that, it also requires elevated privs... the info about the file system privs above was also excellent, even though it wasn't my issue, it DID let me know that I had proper file perms, and could focus on another area... this thread by far was the most helpful of any I've seen. Now to the next step and trying to figure out how to get jconsole to run remotely from another machine - any helpful suggestions are welcome.

Posted by Steven May on April 04, 2009 at 01:39 PM CEST #

Thanks a lot:
- hsperfdata_user explaination saved me with Windows XP use (upcased directory name)

In Linux environment, there is trouble for local process if the java process (mbean) is launched by a system service (with a specific group/owner) and jconsole launched with another account. They should have the same owner for correct working

Posted by SX Tang on October 16, 2009 at 04:34 AM CEST #

My problem with JConsole on Windows was that the only process I could connect to was JConsole itself. Other java processes appeared in the list, but they were grayed out. The suggestion to rename the hsperfdata_<username> folder so that the case matched my username fixed this problem (i.e. hsperfdata_first.last -> hsperdata_First.Last). Note that the case of my username was not the same as the HOME directory that contained the hsperfdata folder (in C:\\Documents and Setttings\\first.last\\Local Settings\\Temp).

Posted by hal9000 on April 13, 2010 at 09:15 AM CEST #

Deleted hsperfdata_%usr% and it is fixed. Thanks!

Posted by guest on March 28, 2011 at 04:28 PM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

lmalvent

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today