VisualVM breaks jetty

2019-05-08 06:24发布

问题:

I'm trying to profile application that is run by "mvn jetty:run", when I connect VisualVM to it and click on Profile jetty crashes with:

Profiler Agent: Waiting for connection on port 5140 (Protocol version: 8)
Profiler Agent: Established local connection with the tool
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6da5e5d4, pid=5124, tid=5704
#
# JRE version: 6.0_16-b01
# Java VM: Java HotSpot(TM) Client VM (14.2-b01 mixed mode windows-x86 )
# Problematic frame:
# V  [jvm.dll+0x1ae5d4]
#
# An error report file with more information is saved as:
# c:\dev\workspaces\credentials\credentialsgui\hs_err_pid5124.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
Profiler Agent: JNI On Load Initializing...
Profiler Agent: JNI OnLoad Initialized succesfully

The same thing I get with different application run using mvn jetty:run.

What's funny is that when I used profiler from NetBeans (should be the same as VisualVM) it works correctly, but I would prefer to use VisualVM any hints on fixing this?

VisualVM from jdk 1.6 (but I used also before a downloadable version).

回答1:

The documentation for VisualVM says that if you are using Java 6 you must turn off class sharing when you start the VM:

To profile an application running on JDK 6, you need to turn off class sharing for the application otherwise the application may crash. To turn off class sharing, start the application with -Xshare:off argument.

I suspect that Maven does not use this option by default when it starts Jetty.