0

As I mentioned in the title,I tried to using btrace to trace the execution of a restful api and got this error:"Handler dispatch failed; nested exception is java.lang.NoSuchFieldError: runtime" when I invoked the restful api.And before I start the btrace process,this restful api works well,once I start the btrace process,this restful api keeps throwing the error everytime ths api is called.

some information:

sping version:4.3.9.RELEASE
btrace version:1.3.12-SNAPSHOT
tomcat version:8.5.34

Restful API(java code):

    @Controller
@RequestMapping("/user")
public class UserInfoController {

    @RequestMapping(value = "/greetting/{name}", method = RequestMethod.GET)
    @ResponseBody
    public WebResponse<String> greet(@PathVariable(value = "name") String name) {
        int a = 1;
        return WebResponseUtil.onSuccess("hello " + name);
    }
}

btrace test class code:

    @BTrace
public class BtraceTest {

//    //获取耗时与方法名
//    @O`enter code here`nMethod(clazz = "com.zrr.controller.UserInfoController", method = "greet", location = @Location(Kind.RETURN))
//    public static void getFuncRunTime(@ProbeMethodName String pmn, @Duration long duration) {
//        println("接口 " + pmn + strcat("的执行时间(ms)为: ", str(duration / 1000000))); //单位是纳秒,要转为毫秒
//    }


    @OnMethod(
            clazz = "com.meituan.zrr.controller.UserInfoController",
            method = "greet",
            location = @Location(Kind.ENTRY)
    )
    public static void getFuncEntry(@ProbeClassName String pcn, @ProbeMethodName String pmn, String name) {
        println("类名: " + pcn);
        println("方法名: " + pmn);

        BTraceUtils.print("入参userName为: ");
        BTraceUtils.printFields(name);
    }
}

I wonder if this has something to do with the btrace version? Hope someone can save me,THANKS!

Akash Shah
  • 596
  • 4
  • 17
mango
  • 1
  • 1

1 Answers1

0

The problem occurred because I put the btrace java files and the test controller java files in the same project. After I put them in two different projects and remove the btrace dependency off the test project,problem solved.

mango
  • 1
  • 1