glassfish
  1. glassfish
  2. GLASSFISH-20716

EntityManager.getDelegate() does not work with Hibernate

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0_b89_RC5
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      When using Hibernate as JPA provider and getDelegate() is called on the EntityManager the following exception is thrown:

      [2013-07-22T09:03:23.856+0200] [glassfish 4.0] [WARNING] [] [javax.enterprise.system.container.ejb.com.sun.ejb.containers] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1374476603856] [levelValue: 900] [[

      javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean: java.lang.AbstractMethodError
      at com.sun.ejb.containers.EJBContainerTransactionManager.checkExceptionClientTx(EJBContainerTransactionManager.java:665)
      at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:507)
      at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
      at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
      at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:220)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
      at com.sun.proxy.$Proxy387.getTableList(Unknown Source)
      at com.prodega.proshop.dao._EJB31_GeneratedCommonsDaoIntf__Bean_.getTableList(Unknown Source)
      at com.prodega.proshop.service.ScheduledJobService.getJobs(ScheduledJobService.java:66)
      at com.prodega.proshop.service.ScheduledJobService.initialize(ScheduledJobService.java:54)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1035)
      at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
      at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
      at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
      at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
      at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:125)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
      at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
      at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:412)
      at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:375)
      at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:1949)
      at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:475)
      at com.sun.ejb.containers.AbstractSingletonContainer.access$000(AbstractSingletonContainer.java:81)
      at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:654)
      at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:396)
      at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:219)
      at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:180)
      at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:158)
      at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:166)
      at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
      at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
      at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
      at com.sun.enterprise.v3.server.ApplicationLoaderService.processApplication(ApplicationLoaderService.java:407)
      at com.sun.enterprise.v3.server.ApplicationLoaderService.postConstruct(ApplicationLoaderService.java:243)
      at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:281)
      at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:328)
      at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:448)
      at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:163)
      at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2204)
      at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:93)
      at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:673)
      at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:660)
      at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpOneJob.run(CurrentTaskFuture.java:490)
      at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpAllTheWay.go(CurrentTaskFuture.java:362)
      at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpAllTheWay.access$100(CurrentTaskFuture.java:279)
      at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture.go(CurrentTaskFuture.java:113)
      at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.proceedTo(AsyncRunLevelContext.java:296)
      at org.glassfish.hk2.runlevel.internal.RunLevelControllerImpl.proceedTo(RunLevelControllerImpl.java:66)
      at com.sun.enterprise.v3.server.AppServerStartup.proceedTo(AppServerStartup.java:532)
      at com.sun.enterprise.v3.server.AppServerStartup.run(AppServerStartup.java:329)
      at com.sun.enterprise.v3.server.AppServerStartup.doStart(AppServerStartup.java:226)
      at com.sun.enterprise.v3.server.AppServerStartup.start(AppServerStartup.java:217)
      at com.sun.enterprise.glassfish.bootstrap.GlassFishImpl.start(GlassFishImpl.java:79)
      at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
      at com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl.start(EmbeddedOSGiGlassFishImpl.java:75)
      at com.sun.enterprise.glassfish.bootstrap.GlassFishDecorator.start(GlassFishDecorator.java:63)
      at com.sun.enterprise.glassfish.bootstrap.osgi.OSGiGlassFishImpl.start(OSGiGlassFishImpl.java:71)
      at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:117)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
      at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:54)
      Caused by: java.lang.AbstractMethodError
      at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:197)
      at com.sun.enterprise.container.common.impl.EntityManagerWrapper.getDelegate(EntityManagerWrapper.java:931)
      at com.prodega.proshop.dao.AbstractBaseDao.getSession(AbstractBaseDao.java:44)
      at com.prodega.proshop.dao.AbstractBaseDao.getTableList(AbstractBaseDao.java:107)
      at com.prodega.proshop.dao.AbstractBaseDao.getTableList(AbstractBaseDao.java:57)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
      at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
      at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4695)
      at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:630)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
      at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
      at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
      at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:582)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
      at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
      at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
      at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4667)
      at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4655)
      at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
      ... 75 more
      ]]

        Activity

        Hide
        Mitesh Meswani added a comment -

        There should be one more nested exception that should be the root cause of "java.lang.AbstractMethodError". Can you please post that too.

        Show
        Mitesh Meswani added a comment - There should be one more nested exception that should be the root cause of "java.lang.AbstractMethodError". Can you please post that too.
        Hide
        Mitesh Meswani added a comment -

        Assigning ownership to Ethan

        Show
        Mitesh Meswani added a comment - Assigning ownership to Ethan
        Hide
        Simon Martinelli added a comment -

        That's all. There is no more stack trace in the log file!

        Show
        Simon Martinelli added a comment - That's all. There is no more stack trace in the log file!
        Hide
        qiang.l.liu added a comment - - edited

        Hi Simon, which version of Hibernate do you use? GF is compatible with JPA2.1, and Hibernate implementation of JPA2.0 will cause such kind of issues. Please refer here for Hibernate's JPA compatibility. https://hibernate.atlassian.net/browse/HHH?selectedTab=com.atlassian.jira.plugin.system.project%3aversions-panel&subset=-1

        Show
        qiang.l.liu added a comment - - edited Hi Simon, which version of Hibernate do you use? GF is compatible with JPA2.1, and Hibernate implementation of JPA2.0 will cause such kind of issues. Please refer here for Hibernate's JPA compatibility. https://hibernate.atlassian.net/browse/HHH?selectedTab=com.atlassian.jira.plugin.system.project%3aversions-panel&subset=-1
        Hide
        Simon Martinelli added a comment -

        I use Hibernate 4.2.3

        Show
        Simon Martinelli added a comment - I use Hibernate 4.2.3
        Hide
        qiang.l.liu added a comment -

        Close the bug as the reporter used Hibernate implementation under JPA2.0

        Show
        qiang.l.liu added a comment - Close the bug as the reporter used Hibernate implementation under JPA2.0
        Hide
        Serge added a comment -

        Hi, Is it ee7/jpa2.1 limitation? I thought old providers should still be usable in ee7 environment.

        Show
        Serge added a comment - Hi, Is it ee7/jpa2.1 limitation? I thought old providers should still be usable in ee7 environment.
        Hide
        qiang.l.liu added a comment -

        Hi Serge, it's not a limitation. It's about the conflict between the version of API(JPA2.1 spec) and the version of implementation(Hibernate implements JPA2.0). The exception is thrown when GF trying to invoke
        public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map), as this is a JPA2.1 interface and the provider Hibernate does implements it, so an AbstractMethodError is thrown out.

        Show
        qiang.l.liu added a comment - Hi Serge, it's not a limitation. It's about the conflict between the version of API(JPA2.1 spec) and the version of implementation(Hibernate implements JPA2.0). The exception is thrown when GF trying to invoke public EntityManager createEntityManager(SynchronizationType synchronizationType, Map map), as this is a JPA2.1 interface and the provider Hibernate does implements it, so an AbstractMethodError is thrown out.
        Hide
        Serge added a comment -

        Ok, why gf call this interface in case of usage of jpa2.0(or may be even lower version but it may be less important) provider and likely there is persistence.xml with version 2.0 also?

        Show
        Serge added a comment - Ok, why gf call this interface in case of usage of jpa2.0(or may be even lower version but it may be less important) provider and likely there is persistence.xml with version 2.0 also?
        Hide
        qiang.l.liu added a comment -

        Currently, GF doesn't check the implementation version of persistence provider.

        Show
        qiang.l.liu added a comment - Currently, GF doesn't check the implementation version of persistence provider.
        Hide
        Serge added a comment -

        is it valid to close this issue as fixed?
        it's either valid issue in my opinion or if there is a decision to support jpa 2.1+ providers only it may be enhancement request, but unfortunately this enhancement is more important now rather the a few years later when all providers will have updated to 2.1+ version.
        If I remember right I was able to use jpa1.0 providers with gf 3.x.

        Show
        Serge added a comment - is it valid to close this issue as fixed? it's either valid issue in my opinion or if there is a decision to support jpa 2.1+ providers only it may be enhancement request, but unfortunately this enhancement is more important now rather the a few years later when all providers will have updated to 2.1+ version. If I remember right I was able to use jpa1.0 providers with gf 3.x.
        Hide
        Mitesh Meswani added a comment -

        Hi Serge,

        As Qiang has mentioned, the root cause of the issues is use of older version of Hibernate with GlassFish 4.0. Adding support for older JPA providers will add complexities to GlassFish code base and testing effort that we are not willing to spend efforts on. That said, I agree with you on the fact that this issue should have been closed as "Works as designed" rather than "fixed.

        -Mitesh

        Show
        Mitesh Meswani added a comment - Hi Serge, As Qiang has mentioned, the root cause of the issues is use of older version of Hibernate with GlassFish 4.0. Adding support for older JPA providers will add complexities to GlassFish code base and testing effort that we are not willing to spend efforts on. That said, I agree with you on the fact that this issue should have been closed as "Works as designed" rather than "fixed. -Mitesh

          People

          • Assignee:
            qiang.l.liu
            Reporter:
            Simon Martinelli
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: