2

I have a simple web application with 1 Message Driven Bean, which WebLogic (12.1.3.0.0) is supposed to inject the EntityManager into. This application has no ejb-jar.xml file. The persistence.xml and the MDB looks like this:

persistence.xml:

<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
                        http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">
  <persistence-unit name="TestAdapterPU">
    <jta-data-source>jdbc/TestDS</jta-data-source>
    <class>com.pol.soem.nobigid.TestData</class>
    <shared-cache-mode>NONE</shared-cache-mode>
  </persistence-unit>
</persistence>

Message Driven Bean:

@MessageDriven(mappedName = "jms/TestQueue", activationConfig = {
@ActivationConfigProperty(propertyName = "connectionFactoryJndiName", propertyValue = "jms/TestCF")
})
public class TestMessageListener implements MessageListener {
    //...

    @Resource
    private MessageDrivenContext mdbContext;    //this one is injected correctly

    @PersistenceContext(unitName = "TestAdapterPU")
    private EntityManager entityManager;

    //entityManager is null at this point
    final List<NobigidData> namedQuery 
        = entityManager.createNamedQuery(NobigidData.QUERY_BYPK, NobigidData.class);    
}

While MessageDrivenContext is injected correctly, the EntityManager is always null, resulting in NullPointerException, when the program reaches the create-named-query line.

The only other place in the application where EntityManager is to be injected is a concrete class. The injection works perfectly there. So it seems WebLogic (12.1.3) has a problem injecting EntityManager to the MDB, for some reason.

Does anyone know what might be the cause of this issue is?

0 Answers0