Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-2256

ExtendedEntityManager injected into Stateless Session Bean

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • None
    • injection
    • None
    • Hide

      Run attached modified Arquillian example:

      1. unzip extended-entity-manager-in-slsb.zip
      2. cd extended-entity-manager-in-slsb
      3. mvn test -Pjbossas-remote-6
      Show
      Run attached modified Arquillian example: unzip extended-entity-manager-in-slsb.zip cd extended-entity-manager-in-slsb mvn test -Pjbossas-remote-6

    Description

      Injecting a Stateless and a Stateful Session Bean - the later with an Extended Presentation Context - into a managed object:

      @RunWith(Arquillian.class)
      public class MyTest {
      
      @EJB
      private MySFSB sfsb;
      
      @EJB
      private MySLSB slsb;
      :
      

      may cause that the ExtendedEntityManager from the SFSB get also injected into the SLSB, which results in:

      java.lang.NullPointerException at org.jboss.ejb3.entity.ExtendedEntityManager.getPersistenceContext(ExtendedEntityManager.java:76)
              at org.jboss.ejb3.entity.ExtendedEntityManager.getEntityManager(ExtendedEntityManager.java:61)
              at org.jboss.ejb3.jpa.integration.JPA2EntityManagerDelegator.createNamedQuery(JPA2EntityManagerDelegator.java:44)
              at MySLSB.foo(MySLSB.java:57)
              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 org.jboss.aop.joinpoint.MethodInvocation.invokeTarget(MethodInvocation.java:122)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:111)
              at org.jboss.ejb3.interceptors.container.ContainerMethodInvocationWrapper.invokeNext(ContainerMethodInvocationWrapper.java:72)
              at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.invoke(InterceptorSequencer.java:76)
              at org.jboss.ejb3.interceptors.aop.InterceptorSequencer.aroundInvoke(InterceptorSequencer.java:62)
      ...
      

      The failure does not occur on each run - sometimes the SLSB get its own org.jboss.jpa.tx.TransactionScopedEntityManager injected as expected, and the test passes.

      Attachments

        1. com.acme.jpa.UserRepositoryTestCase.txt
          14 kB
          Gunter Zeilinger

        Activity

          People

            jaikiran Jaikiran Pai (Inactive)
            gunterze Gunter Zeilinger (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: