Configuring an @MessageDriven bean on JBoss AS7

If you forget to add the destination property to the activationConfig for an MDB, when deploying to JBoss AS7 you’ll get this NullPointerException. Would be better if it told you what required property was missing:

16:30:29,007 WARN  [org.hornetq.ra.inflow.HornetQActivation] (default-short-running-threads-threads - 1) Failure in HornetQ activation org.hornetq.ra.inflow.HornetQActivationSpec(ra=org.hornetq.ra.HornetQResourceAdapter@6ba59338 destination=null destinationType=javax.jms.Queue ack=Auto-acknowledge durable=false clientID=null user=null maxSession=15): java.lang.NullPointerException
    at javax.naming.NameImpl.<init>(NameImpl.java:281) [rt.jar:1.7.0_04]
    at javax.naming.CompositeName.<init>(CompositeName.java:231) [rt.jar:1.7.0_04]
    at org.jboss.as.naming.util.NameParser.parse(NameParser.java:49)
    at org.jboss.as.naming.NamingContext.parseName(NamingContext.java:440)
    at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:213)
    at javax.naming.InitialContext.lookup(InitialContext.java:411) [rt.jar:1.7.0_04]
    at org.hornetq.ra.Util.lookup(Util.java:174) [hornetq-ra-2.2.11.Final.jar:]
    at org.hornetq.ra.inflow.HornetQActivation.setupDestination(HornetQActivation.java:454) [hornetq-ra-2.2.11.Final.jar:]
    at org.hornetq.ra.inflow.HornetQActivation.setup(HornetQActivation.java:287) [hornetq-ra-2.2.11.Final.jar:]
    at org.hornetq.ra.inflow.HornetQActivation$SetupActivation.run(HornetQActivation.java:605) [hornetq-ra-2.2.11.Final.jar:]
    at org.jboss.jca.core.workmanager.WorkWrapper.run(WorkWrapper.java:212)
    at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33)
    at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:801)
    at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45)
    at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:821)
    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_04]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)

Here’s a correctly configured MDB:

@MessageDriven(mappedName = "queue/QueueName", activationConfig = {
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/queueName") })
public class QueueListener implements MessageListener {
...
}

 

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.