2 Replies Latest reply on May 19, 2006 3:15 PM by William DeCoste

    StackOverflowerror when injecting

    aidan davis Newbie

      Hi, I'm trying to have a servlet call a method on a stateless ejb which then calls a method on a stateful ejb. First off, is this allowed?

      If I change the second ejb in the sequence to a stateless ejb, the code works fine, looking at the stack, the problem seems to occur when the 1st ejb (shipfacadebean) attempts to look up and inject an instance of the stateful ejb (objectfacadebean).

      If I change both ejbs to be stateful, i get the same error.

      The Error:

      java.lang.StackOverflowError
       at java.security.AccessController.doPrivileged(Native Method)
       at com.sun.naming.internal.VersionHelper12.getContextClassLoader(VersionHelper12.java:158)
       at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:41)
       at javax.naming.spi.NamingManager.getObjectFactoryFromReference(NamingManager.java:129)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:302)
       at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1110)
       at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1127)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:690)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:51)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
       at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1110)
       at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1127)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:690)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       at javax.naming.InitialContext.lookup(InitialContext.java:351)
       at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1046)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:685)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
       at org.jboss.ejb3.injection.JndiFieldInjector.inject(JndiFieldInjector.java:69)
       at org.jboss.ejb3.interceptor.InterceptorInjector.inject(InterceptorInjector.java:92)
       at org.jboss.ejb3.BaseContext.initialiseInterceptorInstances(BaseContext.java:112)
       at org.jboss.ejb3.stateful.ProxiedStatefulBeanContext.initialiseInterceptorInstances(ProxiedStatefulBeanContext.java:242)
       at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:92)
       at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:48)
       at org.jboss.ejb3.cache.simple.SimpleStatefulCache.create(SimpleStatefulCache.java:206)
       at org.jboss.ejb3.stateful.StatefulContainer.createSession(StatefulContainer.java:220)
       at org.jboss.ejb3.stateful.StatefulLocalProxyFactory.createProxy(StatefulLocalProxyFactory.java:100)
       at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
       at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
       at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1110)
       at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1127)
      
      .....repeated
      
      


      My code is laid out thus:

      The Servlet:

      ShipFacade sf = (ShipFacade) ic.lookup(System.getProperty(APP_NAME + APP_NAME_FACADE));
      
      if(ufilters == null)
      {
       ufilters = sf.getFilters();
      }
      


      The stateless ejb:

      @Stateless
      @SecurityDomain("SMSLDAP")
      public class ShipFacadeBean implements ShipFacade , UserFilteredService {
      
       @EJB private ObjectFacade of;
      ....
      
       public TreeMap<String, DynaBean> getFilters() throws DelegateException {
       log.info("Getting Filters");
       TreeMap<String, DynaBean> ts = of.getAllKeyedValues();
       if(ts.size() == 0)
       {
       log.info("DataBase Keys Empty, reinitialising");
       initialiseShipDB();
       return of.getAllKeyedValues();
       }
       return ts;
       }
      
      ....
      
      
      }
      


      The stateful ejb:

      @Stateful
      @SecurityDomain("SMSLDAP")
      public class ObjectFacadeBean implements ObjectFacade {
      
       @PersistenceContext (unitName="objentity")
       private EntityManager manager;
      
       @Resource
       private SessionContext sc;
      
       public TreeMap<String, DynaBean> getAllKeyedValues()
       {
       log.info("Getting static key list");
       List<PersistentKey> lpk = manager.createNamedQuery("persistentkey.getAllLimited").getResultList();
       TreeMap<String, DynaBean> allKeys = new TreeMap<String, DynaBean>(new Comparator(){
       public int compare(Object o, Object o1) {
       return 1;
       }
       });
      
       for(PersistentKey pk: lpk)
       {
       allKeys.put(pk.getName(), getKeyedValues(pk));
       }
       return allKeys;
       }
      
      }
      
      
      


      Your help appreciated.