users@glassfish.java.net

Re: [glassfish embedded] Retrieving EntityManager in the Jersey XmlAdapter

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Mon, 21 Jun 2010 14:47:18 -0700

Failure of the 1st option (and may be the 2nd) is most probably a classpath
issue. How do you start embedded server?

thanks,
-marina

glassfish_at_javadesktop.org wrote:
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>