14 Replies Latest reply on Nov 8, 2005 3:54 AM by furbern

    Stopping / Starting  Tomcat web applications

    furbern

      I have a requirement to programmatically stop web applications but leave them deployed.

      With standalone Tomcat I would use the manager application and issue:
      http://localhost:8080/manager/stop?path=/examples

      How is this achieved with Jboss. I have tried using via the jmx-console the jboss.web manager for my web application and setting the maxActiveSessions to zero but this fails with:

      javax.management.ReflectionException: Cannot find setter method setModelerType org.apache.catalina.session.StandardManager@aa2b8c
      org.apache.commons.modeler.BaseModelMBean.setAttribute(BaseModelMBean.java:662)
      org.jboss.mx.server.RawDynamicInvoker.setAttribute(RawDynamicInvoker.java:56)
      org.jboss.mx.server.MBeanServerImpl.setAttribute(MBeanServerImpl.java:593)
      org.jboss.jmx.adaptor.control.Server.setAttributes(Server.java:191)
      org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.updateAttributes(HtmlAdaptorServlet.java:221)
      org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:83)
      org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:67)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)


      I am using Jboss 4.0.3

      Thanks in advance for any help.

        • 1. Re: Stopping / Starting  Tomcat web applications
          furbern

          Can I just add some more information:

          I have managed to reduce the number of max active sessions to zero using twiddle. Here is the syntax:

          C:\jboss-4.0.3\bin>twiddle set "jboss.web:host=localhost,path=/tsp,type=Manager" maxActiveSessions=0
          (in this example my webapp is call tsp).

          Although this prevents additional HTTP sessions being created it does not stop any existing session.

          I have also tried invoking the stop with twiddle:
          C:\jboss-4.0.3\bin>twiddle invoke "jboss.web:J2EEApplication=none,J2EEServer=none,j2eeType=WebModule,name=//localhost/tsp" stop

          This works fine and stops the webapp called tsp.

          I then iinvoke the init method which does not error.

          But when I invoke the start method using:
          C:\jboss-4.0.3\bin>twiddle invoke "jboss.web:J2EEApplication=none,J2EEServer=none,j2eeType=WebModule,name=//localhost/tsp" start

          I get the following null pointer exception:

          ERROR BaseModelMBean invoke - Exception invoking method start
          java.lang.NullPointerException

          I would hope that someone has solved this problem and has an example I could use or could point me in the right direction. I am sure it is just my lack of mbean knowledge and the Jboss Microkernel.

          Apologies

          • 2. Re: Stopping / Starting  Tomcat web applications
            furbern

            Some more information on the environment:

            Sun jdk1.5.0_04 and Win XP pro sp2

            • 3. Re: Stopping / Starting  Tomcat web applications
              furbern

              More information:

              The NPE on twiddle start was being thrown by org.jboss.web.tomcat.security.RunAsListener.

              If I comment out this entry in context.xml in jbossweb-tomcat55.sar then the twiddle start works! i.e I can successfully stop and start individual web apps.

              The problem is I am not sure if I need org.jboss.web.tomcat.security.RunAsListener

              Any comments would be greatly appreciated.

              • 4. Re: Stopping / Starting  Tomcat web applications
                starksm64

                The RunAsListener is needed if you are using the web.xml run-as security setting from lifecycle callback methods. If your not using run-as from these contexts you don't need the RunAsListener.

                • 5. Re: Stopping / Starting  Tomcat web applications
                  furbern

                  Thanks Scott for clarifying RunASListener. As I don't use any run-as functionality it's removal from the context.xml is not a problem and allows the twiddle start/stop to work.

                  Having now got a working solution for a standalone 'default' configuration I now need to do the same for a clustered production environment. There are 2 Win2003 servers running 2 instances of Jboss / Tomcat (with replicated HTTP sessions) load balanced by Apache. I am hoping there might be some "cluster" service to achieve stop /start application. If not then the fall back is to run twiddle for each instance of Tomcat.

                  I'll post back my findings.

                  • 6. Re: Stopping / Starting  Tomcat web applications
                    furbern

                    Unfortunately twiddle start does not work when using the standard 'all' configuration. The twiddle stop does successfully stop the web application and browser clients are served the '503 Application not available' and the following is logged by our context listener:

                    2005-10-28 11:43:20,375 INFO [uk.co.woolworths.tsp.utility.ContextListener] Context destroyed

                    When twiddle start command is used (to start web app 'tsp'):

                    twiddle invoke "jboss.web:J2EEApplication=none,J2EEServer=none,j2eeType=WebModule,name=//localhost/tsp" start

                    The following InstanceNotFoundException occurs :


                    2005-10-28 11:43:31,000 INFO [org.jboss.web.tomcat.tc5.session.JBossCacheManager] Starting JBossManager
                    2005-10-28 11:43:31,000 INFO [org.jboss.web.tomcat.tc5.session.JBossCacheManager] We are using mod_jk(2) for load-balancing. Will add JvmRouteValve.
                    2005-10-28 11:43:31,000 ERROR [org.jboss.web.tomcat.tc5.session.JBossCacheManager] Exception starting JBossCacheManager
                    javax.management.InstanceNotFoundException: jboss.web:j2eeType=WebModule,name=//localhost/tsp,J2EEApplication=none,J2EEServer=none is not registered.
                    at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:509)
                    at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:638)
                    at org.jboss.web.tomcat.tc5.session.JBossCacheManager.installJvmRouteValve(JBossCacheManager.java:727)
                    at org.jboss.web.tomcat.tc5.session.JBossCacheManager.startEmbedded(JBossCacheManager.java:771)
                    at org.jboss.web.tomcat.tc5.session.JBossCacheManager.start(JBossCacheManager.java:246)
                    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4057).....


                    This also happens if using the jmx-console interface.

                    It would appear that the stop method when used in a clustered environment is removing the mbean instance and therefore it (and the start method) is not subsequently available to JbossCacheManger.

                    My production environment is using Jboss 4.0.3RC2 and jdk 1.5.0_4 on Windows 2003 Server Standard edition sp1.

                    Should I be using a different mbean because of the clustering?

                    Again any help would be appreciated.

                    • 7. Re: Stopping / Starting  Tomcat web applications
                      brian.stansberry

                      I'll have to look into this. Seems odd that the JBossCacheManager can't find an MBean that twiddle can.

                      • 8. Re: Stopping / Starting  Tomcat web applications
                        furbern

                        Brian,
                        Thanks a lot for your further investigation. I take it you have seen my related posting on the Jboss Cache forum.

                        http://www.jboss.com/index.html?module=bb&op=viewtopic&t=71792

                        • 9. Re: Stopping / Starting  Tomcat web applications

                          Actually this should belong to Clustering forum. But anyway, can you hot deploy your web app under all?

                          If you can, please post a complete stack trace then. Maybe, we have some problem with the lifecycle instantiation.

                          -Ben

                          • 10. Re: Stopping / Starting  Tomcat web applications
                            furbern

                            Ben,
                            Yes I can hot deploy the web application successfully. It is deployed as part of an exploded ear (I'm not sure if that is significant).

                            Can you clarify what level of logging / trace output you require. e.g.
                            1) set log4j limit categories to DEBUG for org.jboss.xxxx.*
                            2) Start jboss
                            3) copy TSP.ear to deploy
                            4) Stop the TSPweb.war application with twiddle
                            5) Start the TSPweb.war application with twiddle to reproduce error
                            4) e-mail boot.log & server.log

                            • 11. Re: Stopping / Starting  Tomcat web applications

                              Please turn on org.jboss.web to DEBUG should be sufficient.

                              Thanks,

                              -Ben

                              • 12. Re: Stopping / Starting  Tomcat web applications
                                furbern

                                Ben,

                                I have just e-mailed boot.log and server.log to you.

                                • 13. Re: Stopping / Starting  Tomcat web applications
                                  brian.stansberry

                                  I had a chance to look further into this, and have opened a JIRA issue for it.

                                  http://jira.jboss.com/jira/browse/JBAS-2422

                                  -Brian

                                  • 14. Re: Stopping / Starting  Tomcat web applications
                                    furbern

                                    Brian,

                                    It looks like you have found the error and therefore I assume you can reproduce it in testing. If you need anymore information or want me to help test the solution then I will be pleased to do so.

                                    I am watching this post and the JIRA issue and therefore will pick up any of your postings. As this is the first time I have made a forum posting resulting in a JIRA issue I am not sure what is the correct procedure.