-
1. Re: Seam2.3 entityManager is always NULL
meewan Nov 30, 2012 6:27 AM (in response to meewan)After more researches, I think the probleme is that the class org.jboss.seam.persistence.ManagedPersistenceContext is never started but I still don't know why.
-
2. Re: Seam2.3 entityManager is always NULL
mmulligan03 Nov 30, 2012 9:26 AM (in response to meewan)From what the comments read, in the JBoss AS 7 documentation, only the EntityManagerFactory is supported not the EntityManager itself. Take a look at the documentation here: https://docs.jboss.org/author/display/AS71/JPA+Reference+Guide?focusedCommentId=52035733#comment-52035733
-
3. Re: Seam2.3 entityManager is always NULL
meewan Nov 30, 2012 11:11 AM (in response to mmulligan03)As I undestand the managerFactory is supported by seam 2.3(which targets jboss 7.1) because in the seam migration documentation (migrate from seam 2.2 to seam2.3) and the jboss documentation do not speak about this but I will try to see. thanks for your help.
-
4. Re: Seam2.3 entityManager is always NULL
mmulligan03 Nov 30, 2012 11:33 AM (in response to meewan)I was able to get around it by using @PersistenceContext instead of @In.
In my case I specified the persistence unit like so:
@PersistenceContext(unitName = "ess")
private EntityManager entityManager;
If you use EntityQuery or EntityHome I had to overide the getEntityManager() method, here is an example:
public class EntityFactoryHome<E> extends EntityHome<E> {
@Override
public EntityManager getEntityManager() {
EntityManager em = null;
EntityManagerFactory emf;
try {
emf = (EntityManagerFactory) InitialContext.doLookup("java:jboss/essEntityManagerFactory");
if (emf != null)
em = emf.createEntityManager();
} catch (NamingException e) {
throw new IllegalStateException("EntityManagerFactory cannot create entity manager");
}
return em;
}
}
-
5. Re: Seam2.3 entityManager is always NULL
maschmid Dec 12, 2012 10:14 AM (in response to meewan)The problem might be that you need to update the namespaces in components.xml (from xmlns:persistence="http://jboss.com/products/seam/persistence" to xmlns:persistence="http://jboss.org/schema/seam/persistence", etc. ) otherwise it won't understand your persistence:managed-persistence-context definition... that's why it may be never started.
-
6. Re: Seam2.3 entityManager is always NULL
meewan Dec 18, 2012 10:26 AM (in response to meewan)Sorry to answer late.
Marek, I tryed your solution but it didn't work.
Matt, your solution worked but it was to heavy to do it on my project.
Thanks for your help.
Meewan
edit 3 : Marek solution was the good one, I was just douing it wrong. thanks angain for your help