2 Replies Latest reply: May 23, 2011 5:12 AM by Sebastien Pennec RSS

NullPointerException in MethodJoinPointGenerator

Sebastien Pennec Newbie

Hi!

 

I'm experiencing a strange problem with JBoss AOP, with JBoss 5.1.0 EAP.

 

Here is a part of my aop.xml file, in the bootstrap directory:

 

   <bean name="AspectManager" class="org.jboss.aop.deployers.AspectManagerJDK5">

          .....

      <property name="enableLoadtimeWeaving">true</property>

      <property name="include">org.jacorb.poa,com.myCompany.util.bus.mdb.</property>

          .....

          </bean>

 

In a jar that is in the deploy directory, I have a jboss-aop.xml file that contains:

 

<aop>

  ...

          <interceptor name="jmsOnMessageInterceptor" class="com.myCompany.util.jms.OnMessageInterceptor" />

          <bind pointcut="execution(public void $instanceof{javax.jms.MessageListener}->onMessage(javax.jms.Message))">

    <interceptor-ref name="jmsOnMessageInterceptor" />

          </bind>

</aop>

 

In the same jar, I have a class that implements the org.jboss.aop.advice.Interceptor interface and simply logs something (for the moment).

 

In the server logs, I can see the following lines:

 

12:28:37,817 DEBUG [Instrumentor] trying to transform com.myCompany.util.bus.mdb.BusMDBBean

...

12:28:37,958 DEBUG [JoinpointSimpleClassifier] javassist.CtMethod@3a509631[public onMessage (Ljavax/jms/Message;)V] method execution joinpoint matches pointcut: execution(public void $instanceof{javax.jms.MessageListener}->onMessage(javax.jms.Message))

12:28:38,942 DEBUG [Instrumentor] was com.myCompany.util.bus.mdb.BusMDBBean converted: true

12:28:39,192 ERROR [SuperClassesFirstWeavingStrategy] java.lang.RuntimeException: Error converting class

...

 

And when the onMessage method is called, I see the following exception:

 

Caused by: java.lang.NullPointerException

          at org.jboss.aop.instrument.MethodJoinPointGenerator.<init>(MethodJoinPointGenerator.java:78)

          at org.jboss.aop.GeneratedClassAdvisor$ClassAdvisorStrategy.getJoinPointGenerator(GeneratedClassAdvisor.java:1314)

          at org.jboss.aop.GeneratedClassAdvisor.getJoinPointGenerator(GeneratedClassAdvisor.java:781)

          at org.jboss.aop.GeneratedClassAdvisor.fullWorkFinalizeMethodChain(GeneratedClassAdvisor.java:635)

          at org.jboss.aop.GeneratedClassAdvisor.finalizeMethodChain(GeneratedClassAdvisor.java:599)

          at org.jboss.aop.GeneratedClassAdvisor.finalizeChains(GeneratedClassAdvisor.java:580)

          at org.jboss.aop.ClassAdvisor.createInterceptorChains(ClassAdvisor.java:609)

          at org.jboss.aop.GeneratedClassAdvisor.access$201(GeneratedClassAdvisor.java:65)

          at org.jboss.aop.GeneratedClassAdvisor$ClassAdvisorStrategy.createInterceptorChains(GeneratedClassAdvisor.java:1306)

          at org.jboss.aop.GeneratedClassAdvisor.createInterceptorChains(GeneratedClassAdvisor.java:410)

          at org.jboss.aop.ClassAdvisor$1.run(ClassAdvisor.java:306)

          at java.security.AccessController.doPrivileged(Native Method)

          at org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:276)

          at org.jboss.aop.AspectManager.initialiseClassAdvisor(AspectManager.java:754)

          at org.jboss.aop.GeneratedClassAdvisor$ClassAdvisorStrategy.initialise(GeneratedClassAdvisor.java:1294)

          at org.jboss.aop.GeneratedClassAdvisor.initialise(GeneratedClassAdvisor.java:146)

          at com.myCompany.util.bus.mdb.BusMDBBean$BusMDBBeanAdvisor.initialise(BusMDBBean$BusMDBBeanAdvisor.java)

          at com.myCompany.util.bus.mdb.BusMDBBean$BusMDBBeanAdvisor.<init>(BusMDBBean$BusMDBBeanAdvisor.java)

          at com.myCompany.util.bus.mdb.BusMDBBean.<clinit>(BusMDBBean.java)

 

Can anybody help me out? Is there a point that I have missed?

 

 

Thanks!

  • 1. NullPointerException in MethodJoinPointGenerator
    Sebastien Pennec Newbie

    Ok I went into the code of the MethodJoinPointGenerator: the MethodInfo that is used in the constructor returns a null "unadvisedMethod". In the MethodInfo constructor, there are two hashes passed as parameters: they usually are different values that return different methods from a "method catalog". It's the MethodHashing.findMethodByHash() that returns the method that corresponds to each hash.

     

     

    In my situation, the findMethodByHash returns null. So either the MethodHashing class populates its "methodHashesByClass" incorrectly and forgets a method, or the class that builds the hash sends in a nonexistent hash.

     

     

    Does it help you help me? I really need to get this working...

     

     

    Here is the code that I am talking about, from MethodInfo:

     

     

       @SuppressWarnings("deprecation")

       public MethodInfo(Class<?> clazz, long hash, long unadvisedHash, Advisor advisor)

       {

          super(advisor, clazz);

     

          try

          {

             this.hash = hash;

             advisedMethod = MethodHashing.findMethodByHash(clazz, hash);

             unadvisedMethod = MethodHashing.findMethodByHash(clazz, unadvisedHash);

             this.setAdvisor(advisor);

          }

          catch (Exception e)

          {

             throw new RuntimeException(e);

          }

       }

  • 2. NullPointerException in MethodJoinPointGenerator
    Sebastien Pennec Newbie

    I finally traced the error down to a classloading issue, probably caused by the presence of the JRebel agent. I'll post more info asap.