3 Replies Latest reply on Jul 12, 2006 5:58 AM by Patrick

    Problem with inheritance and aop in MessageDrivenBeans (Bug?

    Patrick Newbie

      Hi there,

      I am having a problem with inheritance, aop and message driven beans (using JBoss 4.0.4 GA with the EJB 3 option enabled).

      I defined a couple of MDBs which listen to some topics and do nothing than log a little hello in the first instance. So my code looks something like:

      @MessageDriven(
       description="My Message driven bean to test JMS implementation. It does nothing but loggin the log4j.",
       name="LogOneMDB",
       activationConfig={
       @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic")
       ,@ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/one")
       ,@ActivationConfigProperty(propertyName="Durability",propertyValue="Durable")//subscription
       ,@ActivationConfigProperty(propertyName="subscriptionName",propertyValue = "LogOneMDB")
       ,@ActivationConfigProperty(propertyName="clientID",propertyValue = "LogOneMDB")
       }
      )
      public class LogOneMDB extends AbstractMDB implements MessageListener{}
      


      @MessageDriven(
       description="My Message driven bean to test JMS implementation. It does nothing but loggin the log4j.",
       name="LogTwoMDB",
       activationConfig={
       @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Topic")
       ,@ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/two")
       ,@ActivationConfigProperty(propertyName="Durability",propertyValue="Durable")//subscription
       ,@ActivationConfigProperty(propertyName="subscriptionName",propertyValue = "LogTwoMDB")
       ,@ActivationConfigProperty(propertyName="clientID",propertyValue = "LogTwoMDB")
       }
      )
      public class LogTwoMDB extends AbstractMDB implements MessageListener{}
      


      and a (abstract) super class implementing the listener method:

      class AbstractMDB {
       public void onMessage(final Message message) {
       Logger.getLogger(this.getClass()).debug("Received a message.");
       }
      }
      


      If you deploy something like this and send a message to the topic(s) you end up with following exception:

      3459235 [ERROR][JMS SessionPool Worker-58][org.jboss.ejb3.mdb.MDB] Exception in JMSCI message listener
      java.lang.IllegalAccessException: Class org.jboss.aop.joinpoint.MethodInvocation can not access a member of class com.your.package.AbstractMDB with modifiers "public"
       at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:65)
       at java.lang.reflect.Method.invoke(Method.java:578)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
       at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
       at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:201)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.mdb.MDB.localInvoke(MDB.java:865)
       at org.jboss.ejb3.mdb.MDB.localInvoke(MDB.java:844)
       at org.jboss.ejb3.mdb.MDB$MessageListenerImpl.onMessage(MDB.java:1074)
       at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:266)
       at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:902)
       at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)
       at org.jboss.mq.SpySession.run(SpySession.java:323)
       at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:194)
       at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:748)
       at java.lang.Thread.run(Thread.java:595)
      


      Am I overseeing something or is this a bug of the EJB3 MDB implementation?

      Thanks in advance for your help and comments.
      Cheers,

      Patrick