2 Replies Latest reply on Oct 29, 2009 7:13 AM by Wolfgang Knauf

    correct usage of  EntityManager in a thread under JBossAS 4.

    guava Newbie

      Hi,

      I'm looking for a correct way to use an EntityManager inside a thread of JBossAS. I have a EJB3 service object that spins a thread to handle a request. Inside the thread I need to perform a named query using an EntityManager. I tried passing an EntityManager that was obtained using injection in the service object or an EntityManager that was obtained using JNDI lookup inside the thread. But whichever EntittyManager that I obtained, I always get the following error when performing .createNamedQuery on the EntityManager. Any suggetion?

      23:50:53,765 ERROR [STDERR] java.lang.NullPointerException
      23:50:53,765 ERROR [STDERR] at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getNonTxEntityManager(ManagedEntityManagerFactory.java:59)
      23:50:53,765 ERROR [STDERR] at org.jboss.ejb3.entity.ManagedEntityManagerFactory.getTransactionScopedEntityManager(ManagedEntityManagerFactory.java:164)
      23:50:53,765 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntity
      Manager.createNamedQuery(TransactionScopedEntityManager.java:132)
      23:50:53,765 ERROR [STDERR] at coco.nms.router.HeartbeatPacketWorker.getRouter(HeartbeatPacketWorker.java:92)