-
1. Re: JNDI and the EntityManager
alrubinger Sep 25, 2006 3:20 PM (in response to c_eric_ray)By default, the EntityManager isn't placed in JNDI.
To do so, add the property:<property name="jboss.entity.manager.factory.jndi.name" value="java:/yourJndiName"/>
...to persistence.xml, and inject using:@Resource (mappedName="java:/yourJndiName") EntityManager em;
S,
ALR -
2. Re: JNDI and the EntityManager
alrubinger Sep 25, 2006 3:23 PM (in response to c_eric_ray)Ohh, sorry:
<property name="jboss.entity.manager.jndi.name" value="java:/yourEntityManagerName"/> <property name="jboss.entity.manager.factory.jndi.name" value="java:/yourEntityManagerFactoryName"/>
S,
ALR -
3. Re: JNDI and the EntityManager
c_eric_ray Sep 25, 2006 5:58 PM (in response to c_eric_ray)Thanks. BTW, where do I find a list of properties for things like this? I mean, where would I have looked to find the "jboss.entity.manager.jndi.name" was a valid property to use.
-
4. Re: JNDI and the EntityManager
alrubinger Sep 25, 2006 6:57 PM (in response to c_eric_ray)Usually the reference docs are included in the build and ship somewhere within an EJB3 distribution.
Or, if you don't mind a slightly outdated version: http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html_single/index.html
Alternatively, you could just *guess* at property names; sometimes that works. ;)
S,
ALR -
5. Re: JNDI and the EntityManager
laszlo.fogas Oct 14, 2006 7:18 AM (in response to c_eric_ray)can i inject the EntityManager in an entity bean lifecycle method?
or do a jndi lookup?
because i've tried but it does not work. -
6. Re: JNDI and the EntityManager
laszlo.fogas Oct 14, 2006 8:02 AM (in response to c_eric_ray)sorry, plain old jndi lookup works,
Context ctx = new InitialContext(System.getProperties());
Object ref = ctx.lookup("blabla");
but the annotations not.. Would it cause problems that i'm using this solution? -
7. Re: JNDI and the EntityManager
alrubinger Oct 15, 2006 3:53 PM (in response to c_eric_ray)Usually I place the annotation on an instance member of my EJB. You can't inject stuff into a local method variable.
@Resource(mappedName="jndilocation") will do it.
S,
ALR