2 Replies Latest reply on Jul 1, 2009 2:04 PM by Alexander Lengson

    Servlet depending on MBean: loading order

    Alexander Lengson Newbie

      Hello All,

      How to specify that particular servlet in WAR has dependency on MBean and should not be loaded until that MBean is loaded first?
      JBoss ver. 5.0.1.GA

      Thanks,
      Alex.

        • 1. Re: Servlet depending on MBean: loading order
          Peter Johnson Master

          Try adding a depends clause to the WEB-INF/jboss-web.xml file:

          <?xml version="1.0"?>
          <!DOCTYPE jboss-web PUBLIC
           "-//JBoss//DTD Web Application 5.0//EN"
           "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
          <jboss-web>
           <depends>-the mbean name goes here-</depends>
          </jboss-web>


          • 2. Re: Servlet depending on MBean: loading order
            Alexander Lengson Newbie

            PeterJ, thanks a lot!
            This is correct solution.

            That way I am also able to use
            <load-on-startup>1</load-on-startup>
            in web.xml

            I had tried adding similar construction before (but as injection into servlet), and it did not work:

            @Depends({"-the mbean name goes here-"})
            public class JMSEventListenerServlet extends HttpServlet {
            ..
            

            I did get error about not bound JNDI name (that was JMS resource, actually)

            Could you explain please what is the difference between your working solution and that one, which is not?