Question on Interceptor. Getting a Null Pointer!
sushmam Oct 25, 2004 9:55 AMHi,
I'm very new to JBoss-AOP. I've followed the Interceptor example (as given in jboss-3.2.6RC2), in my code. What I need to do, is to calculate the time of execution of a particular method (RubyConnectionManager.getConnection()). I think for that, I need to define point-cuts at the beggining and end of this method, right?
--------------------------------
The Jboss-aop.xml that i've defined is:
<aop> <bind pointcut="execution(public java.sql.Connection com.apple.ist.rubyservice.communication.RubyConnectionManager->getConnection(java.lang.String))"> <interceptor class="com.apple.ist.rubyservice.aspect.RubyServiceInterceptor"/> </bind> </aop>
--------------------------------
Here is the Interceptor code:
public class RubyServiceInterceptor implements Interceptor
{
 public String getName() { return this.getClass().getName(); }
 public Object invoke(Invocation invocation) throws Throwable
 {
 try
 {
 MethodInvocation mi = (MethodInvocation)invocation;
 InvocationResponse ir = (InvocationResponse) invocation.invokeNext();
 logger.info("Intercept complete!!");
 return ir;
 }
 finally
 {
 logger.info("---> Leaving TestInterceptor");
 }
 }
}
--------------------------------
The Stack trace of the null-pointer is:
2004-10-25 19:08:43,082 ERROR [com.apple.ist.rubyservice.server.RubyTxnProcessor] java.lang.NullPointerException
at com.apple.ist.rubyservice.communication.RubyConnectionManager.com$apple$ist$rubyservice$communication$RubyConnectionManager$getConnection$aop(RubyConnectionManager.java)
at com.apple.ist.rubyservice.communication.RubyConnectionManager.getConnection(RubyConnectionManager.java)
at com.apple.ist.rubyservice.communication.RubySession.getConnection(RubySession.java:81)
at com.apple.ist.rubyservice.services.jsql.JsqlExecSqlXmlTxnProcessor.process(JsqlExecSqlXmlTxnProcessor.java:25)
at com.apple.ist.rubyservice.server.RubyTxnProcessor.execute(RubyTxnProcessor.java:43)
at com.apple.ist.rubyservice.server.RubyTxnPoolManager$RubyTxnPoolWorker.run(RubyTxnPoolManager.java:70)
--------------------------------
I'm compiling the code using ANT. here is the ant task:
 <javac srcdir="./src/com/apple/ist/rubyservice/aspects"
 destdir="${ejb.gen.dir}"
 debug="on"
 deprecation="on"
 optimize="off"
 includes="**">
 <classpath refid="project.class.path"/>
 </javac>
 <aopc compilerclasspathref="project.class.path" verbose="true">
 <classpath path="${ejb.gen.dir}"/>
 <src path="${ejb.gen.dir}"/>
 <aoppath path="jboss-aop.xml"/>
 </aopc>
--------------------------------
I would be really grateful if someone could help me out with this.
Thanks and Regards,
Sushma.
 
    