Hi,
I'm having an issue deploying to JBoss 4.0.5-ejb3. When I try to inject my EntityManager in my code:
@PersistenceContext EntityManager em;
it is always null.
However, if I do:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("unitName");
em = emf.createEntityManager();
Where unitName is the persistence unit defined in my persistence.xml file - I get an entityManager instance. But I want it all handled by JBoss.
This is my setup:
I have a java web service that calls my Stateless Session bean. In my session bean, I try to inject the PersistenceContext, so I can utilize my Entity Beans.
I have a .ear archive - with a .war (that contains my web service) and a .jar that contains my beans (entity and session).
I have everything annotated according to the documentation and nothing special in my persistence.xml file, besides the <jta-data-source>. All of the documentation says that it should work.
I wrote a client that calls the web service (Axis 1.3 client generated). It calls the service fine, but I get a NullPointerException when it tries to call the em.persist() method inside my stateless session bean.
Any ideas? If I need to provide more information I can.
Thanks,
Bryan