Posted by jszczepankiewicz
on June 21, 2010 at 2:08 AM PDT
I'm using glassfish 3.0.1 embedded (snapshot from 08-Jun-2010) for testing and standalone glassfish 3.0.1 stable for production. I have to access EntityManager for read operations in the XmlAdapter. I have tried two ways which both work on standalone 3.0.1 glassfish:
1. Using method:
EntityManager em = Persistence.createEntityManagerFactory("brexPU").createEntityManager();
2. Using injection of PU into JNDI and retrieving it in XmlAdapter according to information from:
Both above ways works in standalone glassfish. But unfortunatelly both fails in the glassfish embedded :(.
First method throws RE:
javax.persistence.PersistenceException: No Persistence provider for EntityManager named brexPU
Second method can not found JNDI (the JDNI probably only contains the object:
java:comp/UserTransaction which is not enough for me):
EntityManager entityManager = (EntityManager) initCtx.lookup(
In order to properly test my application i have to have JAX-RS working properly. How can I access EntityManager in the XmlAdapter in the glassfish embedded.
Thanks in advance.