2 Replies Latest reply on Nov 14, 2007 10:01 AM by adrian.brock

    JNDI Binding and ejbcontext test

      The ejbcontext test is failing because it binds the remote proxy at /Stateless
      but then wants to bind the home in a subcontext /Stateless/home

      The /Stateless jndi binding can't be both a binding and a naming context. ;-)

      The same is true for the Stateful bean in this test.

      But this brought up an issue, where the already succesful bindings are not removed
      from jndi, even though the deployment has failed.

      
       public void start() throws Exception
       {
       init();
      
       super.start();
       Class[] interfaces = {ProxyFactory.class};
       String targetId = getTargetId();
       String clientBindUrl = ProxyFactoryHelper.getClientBindUrl(binding);
       Object factoryProxy = createPojiProxy(targetId, interfaces, clientBindUrl);
       log.debug("Binding proxy factory for " + container.getEjbName() + " in JNDI at " + jndiName + PROXY_FACTORY_NAME + " with client bind url " + clientBindUrl);
       try
       {
      
      // OK
      
       Util.rebind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME, factoryProxy);
       }
       catch (NamingException e)
       {
       NamingException namingException = new NamingException("Could not bind stateful remote proxy with ejb name " + container.getEjbName() + " into JNDI under jndiName: " + container.getInitialContext().getNameInNamespace() + "/" + jndiName + PROXY_FACTORY_NAME);
       namingException.setRootCause(e);
       throw namingException;
       }
       assert !Dispatcher.singleton.isRegistered(targetId) : targetId + " is already registered";
       Dispatcher.singleton.registerTarget(targetId, this);
      
       StatefulContainer statefulContainer = (StatefulContainer) container;
       RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
       if (remoteHome != null && !bindHomeAndBusinessTogether(statefulContainer))
       {
       Object homeProxy = createHomeProxy(remoteHome.value());
       String homeJndiName = ProxyFactoryHelper.getHomeJndiName(container);
       log.debug("Binding home proxy at " + homeJndiName);
      
      // OOPS an error doesn't unbind the remote proxy!
      
       Util.rebind(container.getInitialContext(), homeJndiName, homeProxy);
       }
       }
      
      


      THIS IS A MEMORY LEAK!

        • 1. Re: JNDI Binding and ejbcontext test
          wolfc

          Does MC call stop if start fails?
          I thought it did.

          Or in general: should start, on error, set the system in the previous state?
          I'm in favor, but that contradicts MC.

          Enlighten me.

          • 2. Re: JNDI Binding and ejbcontext test

             

            "wolfc" wrote:
            Does MC call stop if start fails?
            I thought it did.

            Or in general: should start, on error, set the system in the previous state?
            I'm in favor, but that contradicts MC.

            Enlighten me.


            Neither the MC. he old JMX kernel or the deployers
            call stop/undeploy() if start/deploy() failed.

            create()/start()/deploy() is expected to clearup after itself if it throws an error.