users@glassfish.java.net

Re: JNDI Lookup of an Entity Manager

From: <glassfish_at_javadesktop.org>
Date: Thu, 08 Jan 2009 07:46:25 PST

Hi Tony,

The lookup string in the helper class ("java:comp/env/persistence/em") correctly matches
the environment dependency name declared in your @PersistenceContext annotation. The
problem is that the helper class is being called from the bean's constructor, where there is
no access to the bean's component environment. Just move it to a @PostConstruct method
or some business method of the bean and it should work.
[Message sent by forum member 'ksak' (ksak)]

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