[jboss-user] [EJB 3.0] - correct usage of EntityManager in a thread under JBossAS 4.

guava do-not-reply at jboss.com
Tue Feb 13 02:54:23 EST 2007


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)


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4015651#4015651

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4015651



More information about the jboss-user mailing list