Does anyone know how to get an EntityManager refernce from withing a statelesss
session bean without using injection?? I have tried the following but with no
success:
| EntityManagerFactory emf = getEntityManagerFactory("MyPersistenceUnitName");
| EntityManager em = emf.createEntityManager();
|
but this just fails with the following exception:
| javax.persistence.PersistenceException: No Persistence provider for
EntityManager named PurchaseNotification
| at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:41)
| at
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
| at
com.squaretrade.queueing.QueueingEngine.execute(QueueingEngine.java:36)
| at sun.reflect.GeneratedMethodAccessor221.invoke(Unknown Source)
| at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
| at
org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
| at
org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
| at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at
org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
| at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at
org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
| at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
| ... 40 more
|
When I use injection it works
| @PersistenceContext(unitName = "MyPersistenceContext")
| EntityManager em;
|
But I need be able to get refernces to EntityManagers for various different
perstence units on the fly from within my session bean so injection is not an
option. any suggestions would be appreciated
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992358#3992358
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992358
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user