开发者

NullPointerException when Starting an application with BTrace agent

开发者 https://www.devze.com 2023-01-26 06:09 出处:网络
I am using BTrace 1.2 and followed user guide from BTrace website. I have no problems using BTrace on running programs with command:

I am using BTrace 1.2 and followed user guide from BTrace website. I have no problems using BTrace on running programs with command:

btrace <pid> AllMethods.class

but when I try to start application with BTrace agent using either:

java -javaagent:btrace-agent.jar=noServer=true,debug=true,script=AllMethods.class,scriptOutputFile=out.trace test/Test

or

btracer AllMethods.class test/Test

I get NullPointerException on SimpleFileOutput:

btrace DEBUG: debugMode is true
btrace DEBUG: unsafeMode is false
btrace DEBUG: dumpClasses is false
btrace DEBUG: stdout is false
btrace DEBUG: probe descriptor path is .
btrace DEBUG: initial script is AllMethods.class
btrace DEBUG: scriptOutputFile not specified. defaulting to AllMethods.class.btrace
btrace DEBUG: java.lang.NullPointerException
java.lang.NullPointerException
 at com.sun.btrace.agent.TraceOutputWriter$SimpleFileOutput.<init>(TraceOutputWriter.java:46)
 at com.sun.btrace.agent.TraceOutputWriter.fileWriter(TraceOutputWriter.java:185)
 at com.sun.btrace.agent.Main.loadBTraceScript(Main.java:334)
 at com.sun.btrace.agent.Main.parseArgs(Main.java:267)
 at com.sun.btrace.agent.Main.main(Main.java:117)
 at com.sun.btrace.agent.Main.pr开发者_运维百科emain(Main.java:101)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
 at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
btrace DEBUG: parsed command line arguments
btrace DEBUG: noServer is true, server not started

I have BTRACE_HOME path configured. Am I missing a trick? I as well tried using release 1.1.3 with no luck.

Please help.


EDIT If I set debug=false and stdout=true and get rid of scriptOutputFile=out.trace output to console works fine.


It turns out the path to scriptOutputFile needs to be absolute so changing scriptOutputFile=out.trace to scriptOutputFile=./out.trace fixed the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号