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:
http://download.oracle.com/docs/cd/B32110_01/web.1013/b28221/servjndi010.htm
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(
"java:comp/env/persistence/brexPU");
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.
[Message sent by forum member 'jszczepankiewicz']
http://forums.java.net/jive/thread.jspa?messageID=475095