开发者

Jconsole cannot connect to java processes running as Windows 7 Services

We have a Java process which we run as a Windows servic开发者_StackOverflowe (using srvany). It runs with Java 1.6 (1.6.0.23 at the moment).

In the past (Windows XP), I could connect JConsole to the processes, on Windows 7 I cannot do this anymore.

If I run jconsole <pid> I get “Invalid process id:4488”. The services are running as SYSTEM user.

If I make the service run as my desktop user (using “Log On as This Account”) the services process ID appear in JConsole, but they are grayed out and I cannot connect.

Is it impossible to dynamically connect to Java processes when they are running as a Windows 7 service?


Perhaps it is a 64bit/32bit problem, I have several applications compiled with 32bit JDK, which could not be opened with JConsole from 64bit JDK on Windows 7 64bit, after I downloaded the 32bit JDK it worked.


Others have been able to run jstack on 2008r2 which may provide some insight on how to get jconsole to connect on Windows 7. As you noted in your comment, the permissions are important. If the service and jconsole can't access the temp directory to write to the appropriate hsperf subdirectory, it won't work. What is also important is the location of the temp directory, the user the service is running, and the user that is running jconsole.

Running SysInternals psexec -s -i <jdk_home>\bin\jconsole <PID> can be used to run jconsole as Local System, the same user that I believe you are using to run your service.

My experience running jconsole from JDK 1.5 in Server 2008 as a system user was unsuccessful. With permissions that I thought should have been sufficient, I got a Could Not Open PerfMemory error. Java 1.6 may be a different story.

In light of all the challenges with running jconsole locally, you would probably have better luck setting it up to accept remote connections. You could set it up for local-only access with your firewall blocking that port from external access.


Add the following to JAVA_OPTION

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

Then, Use JConsole to connecet remote session: localhost:8086


I am currently facing the same problem but on Windows 2003 R2 (SP2). There is on open bug in Oracle Bug database (bug id 6399729) http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6399729

Also there is a work-around posted towards the end. It talks about installing java in "install" mode :-), but didn't work for me on Windows 2003 though. But your mileage may vary!!


Change Environment Variable TEMP and Tmp to a different folder that you created. Like c:\theTemp


It might be a problem with the folder %TMP%/hsperfdata_{USER_NAME}. In my case, it worked after I :

  • close all applications running over the JVM
  • delete the folder %TMP%/hsperfdata_{USER_NAME} (exemple: C:/Temp/hsperfdata_MyUser)
  • reopen JConsole (it recreates the folder)

Hope it helps. You can also take a look at this thread in Oracle community.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜