4 Replies Latest reply on Oct 26, 2004 2:53 AM by sushmam

    Question on Interceptor.  Getting a Null Pointer!

    sushmam

      Hi,

      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.


        • 1. Re: Question on Interceptor.  Getting a Null Pointer!
          bill.burke

          There is no InvocationResponse class. I think you are reading the old O'Reilly article or using the wrong download package? It should be JBoss AOP 1.0.0 FINAL? Try modifying an existing tutorial distribution.

          • 2. Re: Question on Interceptor.  Getting a Null Pointer!
            sushmam

            Thanks. I tried with jboss-aop_1.0.0-FINAL. I modified the MethodInterceptor.java file of method-execution example, that has come along with the jboss-aop distribution. I've included the jars in jboss-32-install folder of the installation, while compiling through aopc task.

            However, the Null-pointer still persists. Could you please guide me as to what could be wrong?

            Thanks,
            Sushma.

            • 3. Re: Question on Interceptor.  Getting a Null Pointer!
              bill.burke

              What VM are you running on? I cannot see anything wrong with your code or XML..

              Are you sure it is not your problem? They NPE seems to be coming from your own code.

              When running with JBoss AOP 1.0.0 Final, do you get the line number for this line:

              com.apple.ist.rubyservice.communication.RubyConnectionManager.com$apple$ist$rubyservice$communication$RubyConnectionManager$getConnection$aop(RubyConnectionManager.java)
              


              Bill



              • 4. Re: Question on Interceptor.  Getting a Null Pointer!
                sushmam

                oops!! It was a mistake in my code. I've fixed it and the interceptor is working fine. Thanks for your help. :)