users@glassfish.java.net

"Couldn't create EntityManager" with OpenJPA-based Kodo.

From: <glassfish_at_javadesktop.org>
Date: Sun, 11 Feb 2007 15:38:55 PST

Hello,

I'm using OpenJPA-based BEA Kodo as JPA engine.

I get an EJBException with the message "Couldn't create EntityManager for refName" when my session beans requesting EntityManager injection (ie. having @PersistenceContext) are created.

The exception is thrown only when it is the first creation of session beans after (re)deployment of my EAR or boot of GlassFish.
Once you get the exception, you never get it unless you redeploy the EAR or restart GlassFish.

When I tried to reduce the number of persistence entity classes (ie. removing classes annotated with @Entity) from 30+ to 3, the exception is not thrown.

I guess that the problem is caused because the JPA engine takes much time to initialize and GlassFish does not wait for the initialization.

I'm suffering from this for a long time, since v2-b13 or older.
GlassFish v2-b32 still have this problem.

Anyone else having this problem ?

===
[#|2007-01-29T10:47:46.710+0900|WARNING|sun-appserver9.1|javax.enterprise.system.container.ejb|_ThreadID=20;_ThreadName=p: thread-pool-1; w: 1517;_RequestID=2136de08-555f-40db-afd5-bd2a4eb90c2d;|create ejblocal object exception
javax.ejb.EJBException: Couldn't create EntityManager for refName: company.wombat.cdms.control.audit.MySessionBeanImpl/entityManager; unitname: null
        at com.sun.ejb.containers.StatefulSessionContainer.createExtendedEMs(StatefulSessionContainer.java:1065)
        at com.sun.ejb.containers.StatefulSessionContainer.createBeanInstance(StatefulSessionContainer.java:895)
        at com.sun.ejb.containers.StatefulSessionContainer.createEJBLocalBusinessObjectImpl(StatefulSessionContainer.java:809)
        at com.sun.ejb.containers.EJBLocalHomeImpl.createEJBLocalBusinessObjectImpl(EJBLocalHomeImpl.java:103)
        at com.sun.ejb.containers.EJBLocalHomeInvocationHandler.invoke(EJBLocalHomeInvocationHandler.java:154)
        at $Proxy107.create(Unknown Source)
        at com.sun.ejb.EJBUtils.resolveEjbRefObject(EJBUtils.java:283)
        at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:868)
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:160)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:313)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:274)
        at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:193)
        at com.sun.enterprise.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:114)
        at com.sun.ejb.containers.StatefulSessionContainer.createBeanInstance(StatefulSessionContainer.java:935)
        at com.sun.ejb.containers.StatefulSessionContainer.createRemoteBusinessObjectImpl(StatefulSessionContainer.java:673)
        at com.sun.ejb.containers.EJBHomeImpl.createRemoteBusinessObjectImpl(EJBHomeImpl.java:110)
        at com.sun.ejb.containers.EJBHomeInvocationHandler.invoke(EJBHomeInvocationHandler.java:176)
        at $Proxy100.create(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:204)
        at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:123)
        at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:196)
        at com.sun.ejb.codegen._GenericEJBHome_Generated_DynamicStub.create(_GenericEJBHome_Generated_DynamicStub.java)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:340)
        at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:61)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:320)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
        at company.wombat.cdms.control.ApplicationSessionControlImpl.lookupBusinessRemote(ApplicationSessionControlImpl.java:217)
        at company.wombat.cdms.control.ApplicationSessionControlImpl.getMySessionBean(ApplicationSessionControlImpl.java:79)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1051)
        at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
        at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2846)
        at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3930)
        at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:190)
        at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:104)
        at $Proxy106.getQuarterlySettlementControl(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:125)
        at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:658)
        at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:198)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1722)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1582)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:964)
        at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:179)
        at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:734)
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:478)
        at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1360)
        at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:509)
|#]
===

Best regards,
- Ryosuke.
[Message sent by forum member 'isana' (isana)]

http://forums.java.net/jive/thread.jspa?messageID=203288