users@glassfish.java.net

Embedded EJB JNDI question

From: NBW <emailnbw_at_gmail.com>
Date: Mon, 2 May 2011 13:18:40 -0400

I have a JUnit test that sparks up an Embedded EJBContainer. I can look up a
SSB with the following:

Map<String, Object> p = new HashMap<String, Object>();
p.put(EJBContainer.APP_NAME, "myApp");
p.put(EJBContainer.MODULES, new File("out/prod/MYAPP");
p.put("org.glassfish.ejb.embedded.glassfish.installation.root",
"C:/glassfish3/glassfish");
EJBContainer ejbC = EJBContainer.createEJBContainer(p);
Context ctx = ejbC.getContext();

(MySSB)ctx.lookup("java:global/myApp/MYAPP/MySSB");

The MODULES path also contains a persistence.xml which defines a JTA
datasource like so:

<persistence-unit name="FOO" transaction-type="JTA">
    <jta-data-source>jdbc/__embeddedMYAPP</jta-data-source>
    ....

My question is, what would be the correct JNDI lookup string to use with ctx
above to get a reference to the EntityManagerFactory and/or EntityManager
provided by this PU? I've tried various things but so far no dice (eg:
"java:global/myApp/MYAPP/jdbc/__embeddedMYAPP" fails). Thanks,

-Noah