Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-8815

Regression in Hibernate session/sessionfactory injection

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Blocker Blocker
    • 6.1.0
    • 6.1.0
    • None
    • None

      Regression caused by fix for JBAS-8563. This impacts the Hibernate specific support mentioned here http://bill.burkecentral.com/2007/07/06/co-existence-with-hibernate-jpa-and-ejb3.

      The regression is that the following will no longer work:

      @PersistenceContext(unitName="custDb") org.hibernate.Session session;
      @PersistenceUnit(unitName="custDb") SessionFactory factory;

      The workaround is to instead use the JPA 2.0 EntityManager.unwrap(Session.class).

      In the following exception, at the point of error. We are in org.jboss.injection.injector.util.FieldInjectionPoint.set() with:
      java.lang.reflect.Field field = org.hibernate.Session org.jboss.ejb3.test.longlived.HibernateShoppingCartBean.em
      this.accessibleObject.type = interface org.hibernate.Session
      target is instance of org.jboss.ejb3.test.longlived.HibernateShoppingCartBean
      value is instance of org.jboss.jpa.util.ExtendedEntityManager

      org.jboss.ejb3.test.longlived.unit.EntityUnitTestCase.testHibernateLongLivedSession fails with error:

      2011-01-18 08:39:08,248 ERROR [org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactoryBase] (WorkerThread#1[127.0.0.1:54163]) Could not obtain new Session ID from SFSB Container: javax.ejb.EJBException: java.lang.IllegalArgumentException: failed to set value ExtendedEntityManager: persistence.unit:unitName=longlived-test.jar#tempdb on field org.hibernate.Session org.jboss.ejb3.test.longlived.HibernateShoppingCartBean.em
      at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:438) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.stateful.StatefulContainer.createSession(StatefulContainer.java:440) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.session.SessionContainer.createSession(SessionContainer.java:677) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactoryBase.getNewSessionId(StatefulSessionProxyFactoryBase.java:227) [:1.0.11]
      at org.jboss.ejb3.proxy.impl.factory.session.stateful.StatefulSessionProxyFactoryBase.createProxyBusiness(StatefulSessionProxyFactoryBase.java:140) [:1.0.11]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_23]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_23]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_23]
      at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_23]
      at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:121) [jboss-aop.jar:2.2.1.GA]
      at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82) [:1.0.1.GA]
      at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:898) [:]
      at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:791) [:]
      at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:744) [:]
      at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:548) [:]
      at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234) [:]
      Caused by: java.lang.IllegalArgumentException: failed to set value ExtendedEntityManager: persistence.unit:unitName=longlived-test.jar#tempdb on field org.hibernate.Session org.jboss.ejb3.test.longlived.HibernateShoppingCartBean.em
      at org.jboss.injection.injector.util.FieldInjectionPoint.set(FieldInjectionPoint.java:73) [:1.0.0-alpha-6]
      at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:159) [:1.0.0-alpha-6]
      at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:134) [:1.0.0-alpha-6]
      at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:82) [:1.0.0-alpha-6]
      at org.jboss.injection.manager.core.DefaultInjectionContext.proceed(DefaultInjectionContext.java:58) [:1.0.0-alpha-6]
      at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.java:58) [:1.0.0-alpha-6]
      at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.java:64) [:1.0.0-alpha-6]
      at org.jboss.ejb3.injection.InjectionInvocation.invokeTarget(InjectionInvocation.java:140) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:125) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor.invoke(CurrentInvocationContextInterceptor.java:47) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:116) [:1.7.19-SNAPSHOT]
      at org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor.invoke(CurrentInvocationInterceptor.java:67) [:1.0.1]
      at org.jboss.ejb3.injection.InjectionInvocation.invokeNext(InjectionInvocation.java:116) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.EJBContainer.injectBeanContext(EJBContainer.java:1363) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.stateful.StatefulContainer.createBeanContext(StatefulContainer.java:184) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.stateful.StatefulContainer.create(StatefulContainer.java:136) [:1.7.19-SNAPSHOT]
      at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:417) [:1.7.19-SNAPSHOT]
      ... 15 more

              smcgowan@redhat.com Shelly McGowan (Inactive)
              smarlow1@redhat.com Scott Marlow
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: