users@glassfish.java.net

Re: CDI _at_PersistenceContext not working when DAO/Bean in own Jar (GFv3)

From: Dominik Dorn <dominik.dorn_at_gmail.com>
Date: Sat, 1 May 2010 10:53:34 +0200

DAO-Jar:
/com/dominikdorn/.../domain/Artist.class
/com/dominikdorn/.../dao/ArtistDao.class
/com/dominikdorn/.../dao/JpaArtistDao.class
/com/dominikdorn/.../domain/Title.class
/com/dominikdorn/.../dao/TitleDao.class
/com/dominikdorn/.../dao/JpaTitleDao.class
/META-INF/persistence.xml
/META-INF/beans.xml


WebApp (War/Exploded):
/index.xhtml
/WEB-INF/web.xml
/WEB-INF/beans.xml
/WEB-INF/lib/dao.jar
/WEB-INF/classes/com/dominikdorn/.../servlets/MySerlvet.class

The Servlet @Injects the DAO (e.g. ArtistDao) which works, however,
the EntityManager in the DAO is not set (annotated with @PersistenceContext)

When I'm copying everything from the DAO-jar to the webapp and remove
the dao-jar from the web-app libs, the entitymanager gets injected as expected.

So, NO ear, NO EJB, just plain CDI with @Inject and the @PersistenceContext.

Does this help?

kr,
dominik