VisualVM“此 JVM 不支持”在所有本地应用程序上?
我已经花了很长时间来加载和测试我的应用程序,现在我需要对其进行分析。但不幸的是,VisualVM 在我的本地应用程序上总是显示“不支持此 JVM”?
这些应用程序是在 VisualVM 的同一 JVM 上启动的。
I have already spent a long time to load and test my application, now I need to profile it. But unluckily, the VisualVM always says "not supported for this JVM" on my local applications?
The applications were started on the same JVM with VisualVM.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
我发现(至少在 Windows 下)可以轻松编写小批处理文件来与特定 JVM 结合运行 VisualVM,这对我来说很重要,因为我已经安装了 32 位 JDK 和 64 位 JDK(我两者都需要,所以这对我来说很明智)。
我在文件夹“S:\applications\visualvm\bin\”中创建了两个批处理文件:
run_32.bat:
run_64.bat:
显然,您的系统上的所有路径可能有所不同,但总体思路应该仍然可以正常工作(在所有64 位版本的 Windows)。好处是,当我想将 VisualVM 与在 32 位 JVM 上运行的 Java 应用程序结合使用时,我可以使用 32 位批处理文件,对于 64 位,依此类推。
“start”命令的唯一好处是批处理文件无需等待其完成即可启动应用程序,因此命令提示符窗口会立即关闭。这不是 VisualVM 的功能,而是 Windows 批处理文件解释器的功能。
I found out that (at least under Windows) one can easily write small batch files to run VisualVM in combination with specific JVMs, which is important for me, since I have installed the 32bit JDK alongside with the 64bit JDK (I need both, so this is sensible for me).
I have created two batch files in the folder "S:\applications\visualvm\bin\":
run_32.bat:
run_64.bat:
Obviously, all paths may differ on your system, but the general idea should still work correctly (on all 64bit versions of Windows). The benefit is that I can use the 32bit batch file when I want to use VisualVM in combination with Java applications that run on the 32bit JVM, and so on for 64bit.
The "start" command has the only benefit that the batch file launches the application without waiting for it to finish, so the command prompt window closes immediately. This is not a feature of VisualVM, but of the Windows batch file interpreter.
就我而言,即使 JVM 匹配(均为 64 位),让事情正常工作的唯一方法是将参数
-Dcom.sun.management.jmxremote
发送到要监视的 JVM。如果您在通过 Java Mission Control (JMC) 连接时遇到问题,这也适用。根据 JMX 文档,该参数的作用如下:
这应该是自动启用的,但由于某种原因它没有在我的 Linux 上启用。
In my case, even with the JVMs matching (both 64-Bit), the only way to get things working was sending the argument
-Dcom.sun.management.jmxremote
to the JVM to be monitored. That also works if you are having problems to connect via Java Mission Control (JMC).According to JMX's documentation, this what the argument does:
This was supposed to be enabled automatically, but for some reason it wasn't on my Linux.
VisualVM 需要使用与要分析的程序相同的 JVM(至少是具有相同 32 位/64 位大小的 Java 6)运行。 (您还需要是同一用户,但此消息不适用)。
我会仔细检查它是否与您的情况完全相同的 JVM。
VisualVM needs to be run with the same JVM - at least Java 6 with the same 32-bit/64-bit size - as the program to be profiled. (You also need to be the same user, but then this message does not apply).
I would be triple-check that it was the exact same JVM in your situation.
在 Linux 上:
确保您的 /etc/hosts 正确引用了您的“主机名”的有效 IP 地址
看来这里的差异完全让可怜的 jvisualvm 及其程序员感到困惑。
On Linux:
Make sure that your /etc/hosts correctly references the effective ip address of your "hostname"
It appears that a discrepancy here totally confuses the poor jvisualvm and its programmers.
我本地tomcat也遇到同样的问题,我在stackoverflow上寻找解决方案。经过一番认真的调试,我发现 VisualGC 没有权限从 tool.jar 文件中获取 GC 信息。
通过链接
http://docs.oracle。 com/javase/7/docs/technotes/tools/share/jstatd.html#SECURITY
https://stackoverflow.com/a/42107355/3876619
我按照以下步骤解决问题
1)创建权限文件
添加
保存
2) 现在将 /tmp/tools.policy 添加到 JVM 启动参数
3) 使用 sudo 运行 jvisualVm
I too got the same problem for local tomcat, I search for solutions for stackoverflow. after some serious debugging, I figured out that VisualGC don't have permissions to get GC informations from tool.jar file.
by links
http://docs.oracle.com/javase/7/docs/technotes/tools/share/jstatd.html#SECURITY
https://stackoverflow.com/a/42107355/3876619
I following steps to solve the issue
1) Create a permission file
Add
save it
2) Now add /tmp/tools.policy to JVM startup parameters
3) Run jvisualVm with sudo
感谢 @user3356656 的提示,我刚刚发现的一个问题是,如果您在计算机位于一个 IP 上时启动程序,然后尝试在另一 IP 上进行连接,则会失败。
An issue that I just found, thanks to the hint from @user3356656, is that if you start the program while your machine is on one IP, and then try to connect while it is on a different IP, it will fail.
我也遇到了这个问题。我的情况是,在 Linux 上,我使用 tomcat_user 启动 tomcat,但使用 root 用户运行 jvisualvm。我用root用户启动tomcat后就可以了。
I also met this issue. My case is that on linux, I started tomcat with tomcat_user but I run jvisualvm with root user. It works after I start tomcat with root user.
我在 Windows 7 上使用 VisualVM 检测本地 Tomcat 安装时遇到问题。我可以手动连接,但内存快照和 VisualGc 插件等功能未启用。我确认我使用的是相同的 JVM 版本、临时文件权限等。但不起作用。然后发现先启动visualvm,再启动tomcat,就解决了问题。
I was having the problem having of visualvm detect my local tomcat installation on Windows 7. I could connect manually, but then things like memory snapshots and visualgc plugin were not enabled. I confirmed that I was using same JVM version, temp file permissions, etc. Didn't work. Then I found that starting visualvm first, and then tomcat, solved the problem.
正如您所看到的,您正在 32 位 JVM 上运行 VisualVM
您无需卸载 32 位 JVM。只需告诉 VisualVM 使用 64 位 JVM。
如果想永久更改,可以
在visualvm_13\etc\visualvm.conf中编辑,并在此处指定jvm的路径
As you can see, you are running VisualVM on 32bit JVM
You don't need to unistall 32bit JVM. Just tell VisualVM to use tour 64bit JVM.
If you want to change it permanently, you can edit
in visualvm_13\etc\visualvm.conf and specify the path of jvm here
我的问题是 JVM 优化 -
-XX:+PerfDisableSharedMem
标志会破坏 VisualGC。如果 jps 不会在列表中显示您的应用程序,这一点就会很明显。My problem was JVM optimizations -
-XX:+PerfDisableSharedMem
flag will break VisualGC. This is apparent if jps will not show your app in the listing.我可以重现下一个行为。
我有一个java应用程序,右键菜单项可以打开jvisualvm。
我正在从bat 文件中将这个java 应用程序作为独立设置运行。
这意味着我修改%path%和其他需要的环境变量,例如JDK
从而形成我的环境。
启动应用程序的 BAT 被标记为以非管理员身份运行。环境指向 64 位 JDK。
然后我以管理员身份启动其他java应用程序。 VM 使用相同的 64 位 JDK 源。
然后我从第一个应用程序中右键单击 ie.as 非管理员启动 jvisualvm。
我可以在 jvisualvm“应用程序列表”中看到该应用程序,但单击“系统属性”会出现错误。消息是“此 JVM 不支持”。
JVM 参数被公开。
解决方案就像之前的一些其他评论一样:
以管理员身份启动右键单击 jvisualvm-starter 我还可以看到“系统属性”。
当然,如果 JDK 是 32 位而其他是 64 位,那么它就无法工作。去过那里。
我认为这里需要添加这个概念。
I can reproduce next behaviour.
I have a java application with right-click menu item to open jvisualvm.
I'm running this java application as standalone setup from a bat file.
It means I modify %path% and other needed environment variables like JDK
accordingly to form my environment.
The BAT that starts application is marked running as non-admin. Environment points to a 64-bit JDK.
Then I start other java application as admin. VM lives from the to same 64-bit JDK-source.
Then I start jvisualvm from first app with the right click ie.as non-admin.
I can see the app in jvisualvm ‘Applications list’ but clickin ‘System properties’ gives error. Message is “Not supported for this JVM”.
JVM arguments are exposed.
Solution is like in some other previous comments:
Starting my right-click jvisualvm-starter as admin I can see also "system properties" .
Certainly if JDKs would be 32-bit and other 64-bit it would not work. been there.
I thought this notion needs to be added here.
就我而言,应用程序以管理员权限运行。因此,visualVM 也需要以管理员身份运行。
In my case, the application was running with admin permissions. So, visualVM also need to be running as admin.
我已将名称更改为我的 Windows 用户并将其全部设置为小写,重新启动我的电脑,现在一切正常。
I have changed name to my Windows User and set it all lowercase, restarted my PC and it all works now.
对我来说,原因是我使用不同的用户和 JVM 进程运行“jstatd”。我在linux中有一个特殊用户来启动JVM线程(它是一个tomcat),但我用root启动jstatd进程。如果使用root运行jps,则看不到属于其他用户的JVM线程的任何信息。这就是麻烦所在。
我杀死了由root启动的“jstatd”进程,su到JVM进程的所有者,然后重新启动“jstatd”进程,现在一切正常了。
For me, the reason is that I have run the "jstatd" with a different user with the JVM process. I have a special user in the linux to start the JVM thread(it is a tomcat), but I start the jstatd process with root. If you use root to run jps, you cannot see any information of the JVM threads belonging to other users. That is the trouble.
I killed the "jstatd" process started by root, su to the owner of the JVM process, and restart the "jstatd" process and everything wokrs fine now.
如果 VVM 启动时出现错误:无法监视本地应用程序(启动时出现错误对话框),它将无法进行分析!
https://visualvm.github.io/troubleshooting.html
本地应用无法监控(错误启动时的对话框)
描述:VisualVM 启动后立即显示错误对话框,指出无法监视本地应用程序。本地运行的 Java 应用程序显示为 (pid ###)。
解决方案:如果用户名包含大写字母,则在 Windows 系统上可能会发生这种情况。在本例中,用户名是 UserName,但 JDK 创建的 jvmstat 目录是 %TMP%\hsperfdata_username。要解决此问题,请退出所有 Java 应用程序,删除 %TMP%\hsperfdata_username 目录并创建新的 %TMP%\hsperfdata_UserName 目录。
if VVM start with an error: Local Applications Cannot Be Monitored (Error Dialog On Startup) , it won't be able to profile!
https://visualvm.github.io/troubleshooting.html
Local Applications Cannot Be Monitored (Error Dialog On Startup)
Description: An error dialog saying that local applications cannot be monitored is shown immediately after VisualVM startup. Locally running Java applications are displayed as (pid ###).
Resolution: This can happen on Windows systems if the username contains capitalized letters. In this case, username is UserName but the jvmstat directory created by JDK is %TMP%\hsperfdata_username. To workaround the problem, exit all Java applications, delete the %TMP%\hsperfdata_username directory and create new %TMP%\hsperfdata_UserName directory.
我有“本地应用程序”节点,即使有其他 Java 进程使用相同的 JRE 版本,该节点也无法被识别。
我建议清理 VisualVM 缓存。这对我有帮助。
打开 VisualVM 节点/进程后,您可以在概述部分找到缓存文件夹,例如:
I had "Local Application" node which was not recognized even there were other Java processes using the same JRE version.
I'd recommend to cleanup VisualVM cache. This helped to me.
You can find cache folder once you open VisualVM node/process, in Overview section, for example: