eclipse-ee4j / glassfish

Eclipse GlassFish
https://eclipse-ee4j.github.io/glassfish/
386 stars 144 forks source link

java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory in case when persistence.xml inside EJB module #21132

Closed glassfishrobot closed 4 years ago

glassfishrobot commented 10 years ago

I have very strange exception in out EE applications, then persistence.xml resides in EJB-jar. I use CDI+EJB in dev environment and qualifies each EntityManager with own CDI qualifer. If I make EntityManager producer bean EJB-bean (@Stateless), every works fine, but if I change it to Managed Bean (@ApplicationScoped) - got the exception below.

Sample application is attached. Have both maven profiles "glassfish3" and "glassfish4".

javax.ejb.EJBException: null
    at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5215) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5113) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4915) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:89) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.proxy.$Proxy178.process(Unknown Source) [na:na]
    at my.domain.application.__EJB31_Generated__TimerBean__Intf____Bean__.process(Unknown Source) [application-ejb-1.0-SNAPSHOT_jar/:na]
    at my.domain.application.TimerBean.onTimeout(TimerBean.java:42) [application-ejb-1.0-SNAPSHOT_jar/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_15]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_15]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_15]
    at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_15]
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49) [weld-osgi-bundle.jar:20120429-1045]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_15]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_15]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_15]
    at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_15]
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundTimeout(SystemInterceptorProxy.java:149) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_15]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_15]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_15]
    at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_15]
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.callEJBTimeout(BaseContainer.java:4058) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.EJBTimerService.deliverTimeout(EJBTimerService.java:1832) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.EJBTimerService.access$100(EJBTimerService.java:108) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.EJBTimerService$TaskExpiredWork.run(EJBTimerService.java:2646) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_15]
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [na:1.7.0_15]
    at java.util.concurrent.FutureTask.run(FutureTask.java:166) [na:1.7.0_15]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_15]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_15]
    at java.lang.Thread.run(Thread.java:722) [na:1.7.0_15]
Caused by: java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName ModulePU
    at com.sun.enterprise.container.common.impl.EntityManagerWrapper.init(EntityManagerWrapper.java:132) ~[container-common.jar:3.1.2.1-SNAPSHOT]
    at com.sun.enterprise.container.common.impl.EntityManagerWrapper.getEntityManagerFactory(EntityManagerWrapper.java:875) ~[container-common.jar:3.1.2.1-SNAPSHOT]
    at my.mydomain.module.ModuleEntityManagerProducer.getEntityManager(ModuleEntityManagerProducer.java:21) ~[module-ejb-1.0-SNAPSHOT_jar/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_15]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_15]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_15]
    at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_15]
    at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267) ~[na:na]
    at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) ~[na:na]
    at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137) ~[na:na]
    at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263) ~[na:na]
    at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:170) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstance(MethodInjectionPoint.java:137) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.ProducerMethod$ProducerMethodProducer.produce(ProducerMethod.java:136) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.AbstractProducerBean$AbstractProducer.produce(AbstractProducerBean.java:319) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.AbstractProducerBean.create(AbstractProducerBean.java:307) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.context.unbound.DependentContextImpl.get(DependentContextImpl.java:68) ~[na:na]
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:637) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.manager.BeanManagerImpl.getReference(BeanManagerImpl.java:703) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.injection.FieldInjectionPoint.inject(FieldInjectionPoint.java:136) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.util.Beans.injectBoundFields(Beans.java:686) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.util.Beans.injectFieldsAndInitializers(Beans.java:695) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1$1.proceed(ManagedBean.java:161) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.glassfish.weld.services.InjectionServicesImpl.aroundInject(InjectionServicesImpl.java:134) ~[weld-integration.jar:3.1.2.1-SNAPSHOT]
    at org.jboss.weld.injection.InjectionContextImpl.run(InjectionContextImpl.java:46) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget$1.work(ManagedBean.java:157) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.ManagedBean$FixInjectionPoint.run(ManagedBean.java:131) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.inject(ManagedBean.java:153) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:293) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:107) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90) ~[weld-osgi-bundle.jar:20120429-1045]
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79) ~[weld-osgi-bundle.jar:20120429-1045]
    at my.mydomain.module.JpaDomainRepository$Proxy$_$$_WeldClientProxy.add(JpaDomainRepository$Proxy$_$$_WeldClientProxy.java) ~[module-ejb-1.0-SNAPSHOT_jar/:na]
    at my.domain.application.TimerBean.process(TimerBean.java:51) [application-ejb-1.0-SNAPSHOT_jar/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_15]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_15]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_15]
    at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_15]
    at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5388) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:42) [weld-osgi-bundle.jar:20120429-1045]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_15]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_15]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_15]
    at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_15]
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_15]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_15]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_15]
    at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_15]
    at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5360) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214) [ejb-container.jar:3.1.2.1-SNAPSHOT]
    ... 43 common frames omitted

Environment

Windows 8.1 Pro x64, JDK 7u13 x64, Maven 3.1

Affected Versions

[3.1.2.2, 4.0]

glassfishrobot commented 6 years ago
glassfishrobot commented 10 years ago

@glassfishrobot Commented alexander.v.morozov said: Sample application archive is here https://www.sendspace.com/file/dra7f2

glassfishrobot commented 10 years ago

@glassfishrobot Commented Was assigned to srini.gf

glassfishrobot commented 7 years ago

@glassfishrobot Commented This issue was imported from java.net JIRA GLASSFISH-21132

glassfishrobot commented 10 years ago

@glassfishrobot Commented Reported by alexander.v.morozov

github-actions[bot] commented 4 years ago

This issue has been marked as inactive and old and will be closed in 7 days if there is no further activity. If you want the issue to remain open please add a comment