On Apr 20, 2010, at 10:30 AM, David Jencks wrote:

I have cmp 2 beans working in geronimo trunk with the following small change to how the cmp engine finds its EM:

Index: container/openejb-core/src/main/java/org/apache/openejb/core/ cmp/jpa/JpaCmpEngine.java
===================================================================
--- container/openejb-core/src/main/java/org/apache/openejb/core/cmp/ jpa/JpaCmpEngine.java (revision 935765) +++ container/openejb-core/src/main/java/org/apache/openejb/core/cmp/ jpa/JpaCmpEngine.java (working copy)
@@ -28,6 +28,7 @@
import javax.ejb.EntityBean;
import javax.ejb.FinderException;
import javax.ejb.RemoveException;
+import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceException;
@@ -90,7 +91,8 @@
private EntityManager getEntityManager(CoreDeploymentInfo deploymentInfo) {
        EntityManager entityManager = null;
        try {
- entityManager = (EntityManager) deploymentInfo.getJndiEnc().lookup("java:comp/env/" + CMP_PERSISTENCE_CONTEXT_REF_NAME); + entityManager = (EntityManager) new InitialContext().lookup("java:comp/env/" + CMP_PERSISTENCE_CONTEXT_REF_NAME);
        } catch (NamingException ignroed) {
        }


This might be marginally slower but since we're about to go talk to a database I don't think creating a couple extra jndi objects will be really noticeable.

Anyone have a problem with me committing this change?

As discussed on IRC, it's fine as a temporary change to get more TCK tests to run.

-David

Reply via email to