2 Replies Latest reply on May 5, 2014 11:08 AM by Jamie Beznoski

    MDBs do not deploy if they inherit MessageListener interface

    Jamie Beznoski Newbie

      Hi all,

       

      First post

       

      I have an issue deploying some MDBs in JBoss EAP 6.2.  Basically, it seems that if the MDB implementations implement an interface that extends the MessageListener interface, they do not deploy.  If your implementation class implements MessageListener directly, or extends a class that implements MessageListener, the bean deploys without issue.

       

      Here's the stack trace that occurs at deployment time:

       

      14:47:41,774 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-14) MSC000001: Failed to start service jboss.deployment.unit."jboss-helloworld-mdb.war".component.HelloWorldQueueMDB.CREATE: org.jboss.msc.service.StartException in service jboss.deployment.unit."jboss-helloworld-mdb.war".component.HelloWorldQueueMDB.CREATE: Failed to start service

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_26]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_26]

          at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_26]

      Caused by: java.lang.IllegalStateException: JBAS014521: No message listener of type org.jboss.as.quickstarts.mdb.HelloWorldQueue found in resource adapter hornetq-ra

          at org.jboss.as.ejb3.component.EJBUtilities.createActivationSpecs(EJBUtilities.java:105)

          at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentCreateService.createComponent(MessageDrivenComponentCreateService.java:98)

          at org.jboss.as.ee.component.BasicComponentCreateService.start(BasicComponentCreateService.java:91)

          at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentCreateService.start(MessageDrivenComponentCreateService.java:80)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.4.GA-redhat-1.jar:1.0.4.GA-redhat-1]

          ... 3 more

       

      Here's a simple example that illustrates the issue (this is a small modification of the "helloworld-mdb" quickstart example):

       

      Interface:

       

      import javax.jms.MessageListener;

       

      public interface HelloWorldQueue extends MessageListener {

      }

       

      Implementation:

       

      @MessageDriven(name = "HelloWorldQueueMDB", activationConfig = {

              @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

              @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/HELLOWORLDMDBQueue"),

              @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge") })

      public class HelloWorldQueueMDB implements HelloWorldQueue {

       

          private final static Logger LOGGER = Logger.getLogger(HelloWorldQueueMDB.class.toString());

       

          public void onMessage(Message rcvMessage) {

              TextMessage msg = null;

              try {

                  if (rcvMessage instanceof TextMessage) {

                      msg = (TextMessage) rcvMessage;

                      LOGGER.info("Received Message from queue: " + msg.getText());

                  } else {

                      LOGGER.warning("Message of wrong type: " + rcvMessage.getClass().getName());

                  }

              } catch (JMSException e) {

                  throw new RuntimeException(e);

              }

          }

      }

       

      I've also attached a zip with this code (again, a small mod of the helloworld-mdb quickstart).

       

      Worth noting this deploys in Weblogic.

       

      I've been able to work around this, but it required some extensive changes to our mock unit test framework - this was the point of using the interfaces to begin with (ease of mocking).

       

      It's similar to [AS7-2638] a Message driven bean that implements MessageListener in a superclass is considered invalid. - JBoss Issue Tr… but is still there in EAP 6.2 (this one was fixed in 7.0.2.Final)