users@glassfish.java.net

Re: How to access EntityManager of a EJB from a WAR? (without using facade pattern)

From: <glassfish_at_javadesktop.org>
Date: Wed, 03 Feb 2010 09:56:02 PST

Hi,

I think you should be able to lookup the EntityManager using JNDI.

Try to define a resource reference to EntityManager first in you war deployment descriptor web.xml, then do JNDI lookup, this may help http://blogs.sun.com/pblaha/entry/how_to_use_entitymanager_api.

As far as I understand the Persistence Unit annotation injection is scoped to the containing EAR or WAR. What you referred to as facade isn't really a facade, it's perfectly right to CRUD through a manager EJB. I don't see a point why you wouldn't manage your entity using a session EJB that's already deployed as ejb-jar.

BR,
Mohamed
[Message sent by forum member 'mohamedelshami' (mohamed.shami_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=384572