Tuesday, March 01, 2011

Profiling OSGi project with Btrace

I met "java.lang.NoClassDefFoundError" when i did profiling with my OSGi project:
Error com.myapp.template.TemplateServlet - TemplateServlet.doGet() exception
java.lang.NoClassDefFoundError: CodeLineTiming at com.myapp.service.proxy.abc.impl.ServiceProxyImpl.$btrace$CodeLineTiming$onCall(ServiceProxyImpl.java) at com.myapp.service.proxy.abc.impl.ServiceProxyImpl.getRfpWithChangeLog(ServiceProxyImpl.java:467) at
...

So two things need to be modified from my side:
1. add package to btrace code , for example "package com.sun.btrace.samples;"
 
 package com.sun.btrace.samples; 

 import com.sun.btrace.annotations.*;  
 import static com.sun.btrace.BTraceUtils.*;  
 import com.sun.btrace.aggregation.*;  
 @BTrace  
 public class MethodResponseTime {  
...
}

2. add OSGI config.properties in felix/conf/ to include org.osgi.framework.bootdelegation=com.sun.btrace,com.sun.btrace.*

Then start your application, enjoy profiling with Btrace:)

Thanks for @yardus great help and also good post from this: http://blogs.sun.com/binublog/entry/glassfish_v3_profiling

No comments:

Post a Comment