-
1. Re: Local JNDI name for EntityManager?
alrubinger Feb 12, 2007 10:07 AM (in response to guava)If you'd like to have the EntityManager and Factory accessible via JNDI, just add these to your persistence.xml (will place in Global scope):
<property name="jboss.entity.manager.jndi.name" value="java:/entityManager" /> <property name="jboss.entity.manager.factory.jndi.name" value="java:/entityManagerFactory" />
S,
ALR -
2. Re: Local JNDI name for EntityManager?
chamillard Feb 16, 2007 1:30 PM (in response to guava)(I'm not the original poster, but I'm having the same problem)
Although I'm using 4.0.4.GA, I tried this by adding the following to my persistence.xml<property name="jboss.entity.manager.jndi.name" value="java:/CoreEntitiesEntityManager" />
I then tried to do a JNDI lookup usingContext ctx = new InitialContext(); EntityManager em = (EntityManager) ctx.lookup("java:CoreEntitiesEntityManager");
but I got the "standard" (at least for me)javax.naming.NameNotFoundException: CoreEntitiesEntityManager not bound
exception when I ran the code.
Does the recommended approach only work in 4.0.5.GA (and not 4.0.4.GA)?
Does it matter that I'm doing this in a Cactus test case?
Isn't there a default JNDI name for an entity manager for a deployed persistence unit? If so, what would the full name be (assuming the app is deployed in "MyApp.ear", with persistence unit name "mypersistenceunit")?
Thanks. -
3. Re: Local JNDI name for EntityManager?
chamillard Feb 16, 2007 1:49 PM (in response to guava)Sorry, I'll answer a couple of my own questions after a little more research:
No default JNDI name for entity manager, so iI need to explicitly include it in persistence.xml.
I still can't get the JNDI lookup to work, though. I also tried using Resource injection (suggested in another post), but I end up with a null entity manager.
Thanks. -
4. Re: Local JNDI name for EntityManager?
chamillard Feb 16, 2007 4:17 PM (in response to guava)Folks,
Sorry to take up bandwidth; I figured it out. My problem was that I put the property tag outside the <persistence-unit> tag in persistence.xml. Putting it inside solved the problem.
Cheers.