jvm-profiling-tools / perf-map-agent

A java agent to generate method mappings to use with the linux `perf` tool
GNU General Public License v2.0
1.65k stars 260 forks source link

Report missing tools.jar in build and run script instead of failing with NoClassDefFoundError #37

Open veastark opened 8 years ago

veastark commented 8 years ago

Hello,

After succesfully creating flamegraphs a few days ago I tried it again today and only get this error:

Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/attach/AgentInitializationException at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.privateGetMethodRecursive(Class.java:3048) at java.lang.Class.getMethod0(Class.java:3018) at java.lang.Class.getMethod(Class.java:1784) at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526) Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AgentInitializationException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 7 more

I haven't changed anything on the machine. Is there a solution to this or a way to get more error information?

jrudolph commented 8 years ago

Hi @VEASTARK, sorry for not answering any sooner. Is this still a problem? It looks like tools.jar is missing from the classpath which can happen if you run with a JRE or with unusual paths.

SerCeMan commented 7 years ago

@VEASTARK try to check that your JAVA_HOME (or /usr/lib/jvm/default_java folder) points to a right folder

jrudolph commented 7 years ago

Let's keep this ticket as a request to enhance the script to check whether the tools.jar exists at the expected location and otherwise fail with a better error message.