Lookup will work on Tomcat also? I can't tie to resource injection
because my persistence classes (brokers) aren't managed (and, of course,
Tomcat don't know anything about managed classes).
Regards,
Edson Richter
glassfish_at_javadesktop.org escreveu:
> No, that pattern is not recommended. It's better to use the Java EE approach, which is to
> obtain container-managed EntityManagers using either
>
> injection :
>
> @PersistenceContext(unitName="GeDoc2PU")
> private EntityManager em;
>
> or lookup :
>
> // put at class-level of a managed class
> @PersistenceContext(name="myPU", unitName="GeDoc2PU")
>
> then somewhere in the code :
>
> InitialContext ic = new InitialContext();
> EntityManager em = (EntityManager) ic.lookup("java:comp/env/myPU");
>
> The approach you're using is too brittle and too tied to classloaders. Let the
> application server manage resources.
> [Message sent by forum member 'ksak' (ksak)]
>
> http://forums.java.net/jive/thread.jspa?messageID=223159
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>
>