glassfish
  1. glassfish
  2. GLASSFISH-8297

Circular or self injection of stateful EJB causes stack overflow

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: V3
    • Fix Version/s: future release
    • Component/s: ejb_container
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      8,297

      Description

      Stack overflow occurs when injecting a stateful ejb ref with @EJB to its own
      bean class, or another stateful bean class.

      This does not seem to occur to stateless.

      Error from server.log:
      ----------------------

      [#|2009-05-12T14:40:40.524-0400|WARNING|glassfish|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=16;_ThreadName=Thread-1;|create
      object exception
      com.sun.enterprise.container.common.spi.util.InjectionException: Exception
      attempting to inject Remote ejb-ref name=test.BarBean/bar,Remote 3.x business
      interface=test.BarIFresolved to intra-app EJB with
      ejb-name=BarBean,ejb-link=BarBean,mappedName=test.BarIF,refType=Session into
      class test.BarBean
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:391)
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:210)
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:132)
      at
      com.sun.ejb.containers.StatefulSessionContainer.createBeanInstance(StatefulSessionContainer.java:558)
      at
      com.sun.ejb.containers.StatefulSessionContainer.createRemoteBusinessObjectImpl(StatefulSessionContainer.java:428)
      at
      com.sun.ejb.containers.EJBHomeImpl.createRemoteBusinessObjectImpl(EJBHomeImpl.java:117)
      at
      com.sun.ejb.containers.EJBHomeInvocationHandler.invoke(EJBHomeInvocationHandler.java:194)
      at $Proxy111.create(Unknown Source)
      at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
      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:234)
      at
      com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:153)
      at
      com.sun.corba.ee.spi.orbutil.proxy.CompositeInvocationHandlerImpl.invoke(CompositeInvocationHandlerImpl.java:84)
      at $Proxy113.create(Unknown Source)
      at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
      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:419)
      at
      com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:70)
      at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
      at
      com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:427)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at
      com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:106)
      at
      com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:534)
      at
      com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:461)
      at
      com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:139)
      at
      com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:418)
      at javax.naming.InitialContext.lookup(InitialContext.java:392)
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:291)
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:210)
      at
      com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectInstance(InjectionManagerImpl.java:132)
      at
      com.sun.ejb.containers.StatefulSessionContainer.createBeanInstance(StatefulSessionContainer.java:558)
      at
      com.sun.ejb.containers.StatefulSessionContainer.createRemoteBusinessObjectImpl(StatefulSessionContainer.java:428)
      at
      com.sun.ejb.containers.EJBHomeImpl.createRemoteBusinessObjectImpl(EJBHomeImpl.java:117)
      at
      com.sun.ejb.containers.EJBHomeInvocationHandler.invoke(EJBHomeInvocationHandler.java:194)
      at $Proxy111.create(Unknown Source)
      at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
      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:234)
      at
      com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:153)
      at
      com.sun.corba.ee.spi.orbutil.proxy.CompositeInvocationHandlerImpl.invoke(CompositeInvocationHandlerImpl.java:84)
      at $Proxy113.create(Unknown Source)
      at sun.reflect.GeneratedMethodAccessor50.invoke(Unknown Source)
      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:419)
      at
      com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:70)

      bean classes:
      --------------
      //@Stateless
      @Stateful
      @Remote(BarIF.class)
      public class BarBean {
      @EJB
      private FooIF foo;

      // @EJB
      // private BarIF bar;

      public String hello(String name)

      { return "Hello, " + name + " from " + this; }

      }

      ------


      //@Stateless
      @Stateful
      @Remote(FooIF.class)
      public class FooBean {
      @EJB
      private FooIF foo;

      @EJB
      private BarIF bar;

      public String hello(String name) { return "Hello, " + name + " from " + this; }

      }

      After stack overflow, need to kill the appserver process. stop-domain didn't
      stop the process and log files kept growing and rotating.

        Activity

        Hide
        Cheng Fang added a comment -

        Created an attachment (id=2794)
        test WAR file (/web3/Servlet3)

        Show
        Cheng Fang added a comment - Created an attachment (id=2794) test WAR file (/web3/Servlet3)
        Hide
        ksak added a comment -

        This is actually spec-defined behavior since injection of a stateful session bean is required to have the
        side effect of creating a new bean identity, which then results in injection. The same behavior existed in
        V2, so ultimately this is an application coding error. It's possible we could add some kind of check to the
        container but it might not be easy for the container to identify this case at runtime. Changing to P4.

        Show
        ksak added a comment - This is actually spec-defined behavior since injection of a stateful session bean is required to have the side effect of creating a new bean identity, which then results in injection. The same behavior existed in V2, so ultimately this is an application coding error. It's possible we could add some kind of check to the container but it might not be easy for the container to identify this case at runtime. Changing to P4.
        Hide
        Tom Mueller added a comment -

        Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

        Show
        Tom Mueller added a comment - Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.
        Hide
        Tom Mueller added a comment -

        Reassigning to component lead as the assignee is no longer with the project.

        Show
        Tom Mueller added a comment - Reassigning to component lead as the assignee is no longer with the project.

          People

          • Assignee:
            marina vatkina
            Reporter:
            Cheng Fang
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: