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 {
...
}

 

Location of JPA persistence.xml to auto find entities

I’m working on some example code to show different configuration options and approaches for using Hibernate with JPA. I just noticed that the location of the /META-INF/persistence.xml file is critical to allow Hibernate to auto-locate your annotated entities.

In order for the auto location to work (to avoid having to explicitly list annotated entities in your persistence.xml or hibernate.cfg.xml files), the persistence.xml file must be bundled in the same jar as the entities. If you move the file elsewhere, then the entities are not found, even if they are in the classpath. To workaround this, if you do need to put the persistence.xml file in a different location, use the <mapping> element to explicitly declare the entities.

Updating/adding kernel headers to Fedora to support VirtualBox Guest Additions

Installing VirtualBox Guest Additions on Fedora 16 and 17 fails because it looks like the kernel headers are not installed by default. After you’ve installed Fedora to VirtualBox, you can manually install the required kernel headers with these steps (summarized from this post)

sudo yum -y update kernel
sudo yum -y install kernel-devel kernel-headers dkms gcc gcc-c++

Reboot then install the VirtualBox Guest Additions from the Devices menu.

Adding a user on Fedora to sudoers

When you create a new user on Fedora during the setup steps, there’s a checkbox to add the user to the administers group, which allows them to sudo commands. If you forget to check this box, you can add the user to the sudoers group like this:

echo 'loginname ALL=(ALL) ALL' >> /etc/sudoers