4 Replies Latest reply on Aug 21, 2003 10:36 AM by Michael Remijan

    Howto listen for re-deployment?

    Michael Remijan Newbie

      Hi,

      When a servelt gets undeployed, either though a hot re-deployment or some other means, I'd like to be able to capture that event some how so I can cleanup some resources. I tried the servlet.destroy() method but that doesn't seem to work. Is this capturable?

      Thanks
      Mike

        • 1. Re: Howto listen for re-deployment?
          Raja Master

          I have this in my servlet

          public void destroy() {
          .......
          }

          and it gets invoked at the undeploy operation. IS this the same that u are using?

          -Raj

          • 2. Re: Howto listen for re-deployment?
            Michael Remijan Newbie

            Yes, I have this method implemented in my servlet. Right now all I have is a system.out.println() statment to verify that it is being called. When I do a hot re-deployment, however, I never see the output on the console, so i'm assuming it's not being called. I'm using jboss-3.2.1-tomcat-4.1.24

            Mike

            • 3. Re: Howto listen for re-deployment?
              Raja Master

              Mike,
              I just wrote a piece of code to test this, This is my servlet


              import javax.servlet.http.HttpServlet;
              import javax.servlet.http.HttpServletResponse;
              import javax.servlet.http.HttpServletRequest;
              import javax.servlet.ServletException;
              import javax.naming.InitialContext;
              import javax.naming.NamingException;
              import java.io.IOException;
              import java.io.PrintWriter;

              /**
              * @web.servlet name="TestServlet"
              *
              * @web.servlet-mapping url-pattern="/test"
              */
              public class TestServlet extends HttpServlet {
              public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
              PrintWriter out = res.getWriter();
              out.println("In doGet");
              }

              public void destroy() {
              System.out.println("Here in destroy");
              }
              }

              And this is what i get in my console when i redeploy it.
              11:16:34,590 INFO [STDOUT] Here in destroy

              Im using jboss-3.0.4 with tomcat.

              -Raj

              • 4. Re: Howto listen for re-deployment?
                Michael Remijan Newbie

                arrrgh!!! all my fault. I had Destroy() not destroy(). Sorry about that.

                Mike