尝试通过 JMX 连接时,本地 java 进程变灰

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5967281/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 13:44:31  来源:igfitidea点击:

Local java processes are grayed when trying to connect via JMX

javajconsole

提问by richs

I'm running a number of java processes on a windows XP professional machine. When i attempt to connect to these processes via a local JConsole the processes are grayed out.

我在 Windows XP 专业机器上运行了许多 java 进程。当我尝试通过本地 JConsole 连接到这些进程时,这些进程是灰色的。

However i can run the same processes on another machine and connect via a local JConsole on that machine.

但是,我可以在另一台机器上运行相同的进程,并通过该机器上的本地 JConsole 进行连接。

Both machines are running java 1.6 version for the processes and jconsole.

两台机器都为进程和 jconsole 运行 java 1.6 版本。

Any ideas why these processes are grayed out?

任何想法为什么这些过程变灰?

回答by RegRog

I'm fighting with this issue right now and I found out a work around:

我现在正在解决这个问题,我找到了一个解决方法:

You can change the local user's temp dir to something that they can definitely access (e.g. D:\temp). Make sure to do this for the process you're trying to monitor and the jconsole process.

您可以将本地用户的临时目录更改为他们绝对可以访问的内容(例如 D:\temp)。确保为您尝试监视的进程和 jconsole 进程执行此操作。

Another thing that can apparently cause issues are usernames with uppercase letters in them. The directory will always be created with all lowercase letters, but simply renaming it to exactly how it's being shown in the Task Manager made all the issues go away: http://planeofthought.com/wp/?p=75

另一件显然会导致问题的事情是其中包含大写字母的用户名。该目录将始终使用所有小写字母创建,但只需将其重命名为它在任务管理器中的显示方式即可使所有问题消失:http: //planeofthought.com/wp/?p=75

回答by jtahlborn

if the processes are running as a different user (e.g. if you start them as services), then you won't be able to connect to them. also, if they are running under an older jvm, you most likely won't be able to talk to them either.

如果进程以不同的用户身份运行(例如,如果您将它们作为服务启动),那么您将无法连接到它们。此外,如果他们在较旧的 jvm 下运行,您很可能也无法与他们交谈。

in some cases, the local jmx communication mechanism uses the local filesystem and may have issues if permissions are not defined correctly. are you possibly running any of these processes on networked filesystems (nfs, samba)?

在某些情况下,本地 jmx 通信机制使用本地文件系统,如果权限定义不正确,可能会出现问题。您是否可能在网络文件系统(nfs、samba)上运行这些进程中的任何一个?

回答by Roland

Say your windows user name you use to start your java application seen in task manager is YOUR_USER_NAME. Please check a folder whose name looks like hsperfdata_XXXXX (XXXXX should be your user name) in your temp folder and make sure YOUR_USER_NAME and XXXXX are exactly the same (be careful about the upper and lower case).

假设您用来启动在任务管理器中看到的 Java 应用程序的 Windows 用户名是 YOUR_USER_NAME。请检查您的临时文件夹中名称类似于 hsperfdata_XXXXX(XXXXX 应该是您的用户名)的文件夹,并确保 YOUR_USER_NAME 和 XXXXX 完全相同(注意大小写)。

回答by Tomasz Nurkiewicz

From http://download.oracle.com/javase/6/docs/technotes/guides/management/jconsole.html:

http://download.oracle.com/javase/6/docs/technotes/guides/management/jconsole.html

Applications that are not attachable, with the management agent disabled. These include applications started on a J2SE 1.4.2 platform or started on a J2SE 5.0 platform without the -Dcom.sun.management.jmxremoteor com.sun.management.jmxremote.portoptions. These applications appear grayed-outin the table and JConsole cannot connect to them. In the example connection dialog shown in Figure 3-1, the Anagrams application was started with a J2SE 5.0 platform VM without any of the management properties to enable the JMX agent, and consequently shows up in gray and cannot be selected.

不可附加的应用程序,禁用了管理代理。这些包括在 J2SE 1.4.2 平台上启动的应用程序或在没有-Dcom.sun.management.jmxremotecom.sun.management.jmxremote.port选项的 J2SE 5.0 平台上启动的应用程序。这些应用程序在表中显示为灰色,并且 JConsole 无法连接到它们。在图 3-1 所示的示例连接对话框中,Anagrams 应用程序使用 J2SE 5.0 平台 VM 启动,没有任何管理属性来启用 JMX 代理,因此显示为灰色且无法选择。

Figure 3-1 Creating a Connection to a Local Process
(source: oracle.com)

图 3-1 创建到本地进程的连接
(来源:oracle.com

Despite what's being written in the documentation, most likely your process is running under a different user. You can run jconsoleas an administrator and try then.

不管文档中写了什么,很可能你的进程是在不同的用户下运行的。您可以jconsole以管理员身份运行,然后尝试。

回答by Ayodeji Babaniyi

Here is what worked for me. I changed my %TEMP%and %TMP%environment variables to point to a folder I created in my %HOME%location (like C:\Users\[YOUR_NAME]\Temp). Once I did this, all problems vanished.

这对我有用。我更改了我的%TEMP%%TMP%环境变量以指向我在我的%HOME%位置创建的文件夹(如C:\Users\[YOUR_NAME]\Temp)。一旦我这样做了,所有的问题都消失了。

回答by Nikhil

Change your TEMP paths in Environment Variables to something like D:\temp as it could be a permission issue. Fixed this issue for me

将环境变量中的 TEMP 路径更改为 D:\temp 之类的内容,因为这可能是权限问题。为我解决了这个问题

回答by evgeny9

I had the problem as described earlier, but was advised a simpler solution: just close all programs using Java ("IntelliJ IDEA", "SoapUI", etc. - to unlock the temporary folder) and then delete %TMP%\hsperfdata_<user.name>folder. Then, after opening any Java program, this folder will be recreated but this time with correct name (most likely %TMP%\hsperfdata_<User.Name>). And after that, local Java processes can be monitored through "JConsole" or "VisualVM" (now runs without starting error with a link to VisualVM: Troubleshooting Guide) again.

我遇到了前面描述的问题,但建议使用更简单的解决方案:只需关闭所有使用 Java 的程序(“IntelliJ IDEA”、“SoapUI”等 - 解锁临时文件夹),然后删除%TMP%\hsperfdata_<user.name>文件夹。然后,在打开任何 Java 程序后,将重新创建此文件夹,但这次使用正确的名称(最有可能是%TMP%\hsperfdata_<User.Name>)。之后,本地 Java 进程可以通过“JConsole”或“VisualVM”(现在运行没有启动错误,链接到VisualVM:故障排除指南)再次监视。

回答by Pranjal Gohain

instead of this steps you can just goto the CMD and then type in jconsole.exe (PID)

而不是这些步骤,您只需转到 CMD,然后输入 jconsole.exe (PID)

Remember to go to the path where jconsole is present and then run the executable file.

记得去jconsole所在的路径,然后运行可执行文件。

回答by Marcelino Galarza

Change the name of the hsperfdata folder which for me was found at C:\Users\pmimgg0\AppData\Local\Temp\hsperfdata_pmimgg0 to match the User name found on task manager. Once I changed hsperfdata_pmimgg0 to hsperfdata_PMIMGG0 my local process was no longer greyed out on jconsole.

更改我在 C:\Users\pmimgg0\AppData\Local\Temp\hsperfdata_pmimgg0 找到的 hsperfdata 文件夹的名称,以匹配在任务管理器上找到的用户名。将 hsperfdata_pmimgg0 更改为 hsperfdata_PMIMGG0 后,我的本地进程在 jconsole 上不再显示为灰色。

enter image description here

在此处输入图片说明