On Aug 17, 2009, at 10:43 AM, David Blevins wrote:

I tried the latest EclipseLink version with our jpa-eclipselink example to see if maybe they updated their JTATransactionManager class in a way that is incompatible with prior versions. All ran fine there, so we can rule that out:

[..]

INFO - Deployed Application(path=classpath.ear)
[EL Info]: 2009-08-17 10:29:36.045--ServerSession(1631558)-- EclipseLink, version: Eclipse Persistence Services - 1.1.2.v20090612- r4475 [EL Info]: 2009-08-17 10:29:36.38--ServerSession(1631558)--file:/ Users/dblevins/work/openejb3/examples/jpa-eclipselink/target/ classes/-movie-unit login successful Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.833 sec

Hey Jim,

Wonder if this might be your situation too:

  
http://www.nabble.com/rg.apache.openejb.OpenEJBException%3A-Unable-to-determine-the-module-type-of-tp24921373p25013439.html

See my followup and mod the "EMFProvider" class you have and have it do the getResources() check I mention there.

That may help us narrow down your issue.

On a side note, that EMFProvider would make one great Singleton bean:

    import javax.ejb.Lock;
    import static javax.ejb.LockType.READ;
    import javax.ejb.Singleton;
    import javax.persistence.EntityManager;
    import javax.persistence.EntityManagerFactory;
    import javax.persistence.PersistenceUnit;


    @Singleton
    @Lock(READ)
    public class EMFProvider {

        @PersistenceUnit(unitName = "daosample")
        private EntityManagerFactory emf;

        public EntityManager getEM() {
            return getEMFactory().createEntityManager();
        }

        public EntityManagerFactory getEMFactory() {
            return emf;
        }
    }

The result is an bean which is scoped at the app level just as if it was a static. It's more thread safe -- the previous getEMFactory() code could result in many EntityManagerFactory instances being created. You also no longer need to actively clean up the EntityManagerFactory as the container will do that for you.

That said, I'd get the classloading issues sorted out before proceeding -- if things don't work now with the java se "Persistence.createEntityManagerFactory" approach, they won't work when OpenEJB attempts to make the same call.

-David

Reply via email to