2 Replies Latest reply on Apr 26, 2010 4:34 AM by Alexander Eckert

    Undeployment order WAR/EJB

    Alexander Eckert Newbie

      Hi,

       

      when shutting down JBoss 5.1.0.GA I'll get an NPE because the destroy method of a servlet tries to call a local EJB which is already undeployd. There are no problems when using JBoss 4.2.2.GA. I build a small ear reducing it to a minimal application.

       

      I have the EJB:

       

      {code}package helloworld.server;

      import javax.ejb.SessionBean;

      /**
      * @ejb.bean
      *         name="hw/ResourceBean"
      *         type="Stateless"
      *         view-type="local"
      *      local-jndi-name="hw/ResourceBeanLocal"
      *     
      */
      public abstract class ResourceBean implements SessionBean {
         
         /**
          * @ejb.interface-method
          */
          public void startUp() {
              System.out.println(">> start up");
          }
         
          /**
           * @ejb.interface-method
           */
          public void shutDown() {
              System.out.println(">> shut down");
          }
      }{code}

       

      And the Servlet

       

       

      {code}


      import helloworld.common.ResourceBeanUtil;

       

      import javax.servlet.http.HttpServlet;

       

      /**
      * @web.servlet
      *        name="HelloServlet"
      *        load-on-startup="1"
      *
      * @web.servlet.mapping
      *         url-pattern="/hello-web/HelloServlet"
      *
      * @web.ejb-local-ref
      *        name ="ejb/hw/ResourceBeanLocal"
      *      type="Session"
      *      home="helloworld.common.ResourceBeanLocalHome"
      *      local="helloworld.common.ResourceBeanLocal"
      *      link="hello.jar#hw/ResourceBean"
      *
      */
      public class HelloServlet extends HttpServlet {
          private static final long serialVersionUID = 1L;

       

          public void init() {
              try {
                  ResourceBeanUtil.getLocalHome().create().startUp();
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
         
          public void destroy() {
              try {
                  ResourceBeanUtil.getLocalHome().create().shutDown();
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      } {code}

       

      The EAR contains hello.jar (holding the EJB) and hello.war (holding the servlet). I used the default server as base and changed java2ClassLoadingCompliance to true an commented out the WarClassLoaderDeployer bean in deployers\jbossweb.deployer\META-INF\war-deployers-jboss-beans.xml.

       

      I added a jboss-dependency.xml in WEB-INF of the war file with a reference to jndi:hw/ResourceBeanLocal. But it had no effect. Deployment order is still fine but the EJB is still undeployed before the servlet.

       

      Hope you can help