aragozin / jvm-tools

Small set of tools for JVM troublshooting, monitoring and profiling.
Apache License 2.0
3.32k stars 518 forks source link

Add documentation about connecting to JVMs #33

Closed gquintana closed 5 years ago

gquintana commented 6 years ago

As a newcomer, I wish I had read some advice to troubleshoot connection between sjk and my app:

$ java -jar sjk.jar ttop -p <pid>
Failed to access MBean server: <pid>

This would have saved me hours of investigation.

aragozin commented 6 years ago

Good point!

I can recall one more reason. Target JVM may have -Dtmp.io.dir pointing to non-defalt location.

I would extend error message.

eugeniyk commented 6 years ago

@aragozin you can also add JDK installed as prerequisite since with JRE it can't attach

Java home points to /usr/java/jre1.8.0_66 make sure it is not a JRE path
Failed to add tools.jar to classpath
java.lang.ClassNotFoundException: com.sun.tools.attach.VirtualMachine
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.gridkit.lab.jvm.attach.AttachAPI.<clinit>(AttachAPI.java:45)
    at org.gridkit.lab.jvm.attach.AttachManager.<clinit>(AttachManager.java:73)
    at org.gridkit.jvmtool.JmxConnectionInfo.getMServer(JmxConnectionInfo.java:72)
    at org.gridkit.jvmtool.cmd.GcRepCmd$GcRep.run(GcRepCmd.java:63)
    at org.gridkit.jvmtool.cli.CommandLauncher.start(CommandLauncher.java:133)
    at org.gridkit.jvmtool.SJK.main(SJK.java:11)
aragozin commented 5 years ago

Error message now points to https://github.com/aragozin/jvm-tools/blob/master/sjk-core/docs/TROUBLESHOOTING.md