9 Replies Latest reply on Jul 17, 2002 8:31 PM by Julian Gosnell

    how to restart a Jetty web app (so that it's classes are rel

    Scott Sayles Newbie

      I'm running JBoss 3.0.0 with Jetty. I am deploying to an unpacked ear directory which contains a web application. I'd like to be able to deploy updated classes to the web application and have it redeploy, or restart, or whatever that needs to happen to make the classes reload. It seems like this should be possible but every time I try to restart the web app or the Jetty service, this does not appear to happen. Is this possible? I'm attempting to restart the application context via the JMX admin interface.

      Restarting the entire application itself is not an option (like by touching application.xml). We have a custom JCA adapter that breaks if it is reloaded. I want to restart the specific web application only.

      hmm... the classes that I am testing against are actually updating a jar file under WEB-INF/lib. Would it make a difference if I deployed the files unjarred to WEB-INF/lib/classes? I'll give that a try, but could someone confirm that this is possible?

      Thanks

      Scott

        • 1. Re: how to restart a Jetty web app (so that it's classes are
          Adrian Brock Master

          If you unpack the ear, I think you can
          just reload the web app by touching the WEB-INF/web.xml

          Can't say I've tried this myself, but I've been told
          this is how it works.
          Please post your result.

          Regards,
          Adrian

          • 2. Re: how to restart a Jetty web app (so that it's classes are
            Julian Gosnell Expert

            If this works, would you let me know - I;ll stick it in the FAQ.

            Jules

            • 3. Re: how to restart a Jetty web app (so that it's classes are
              Scott Sayles Newbie

              Sorry for not getting back sooner...

              Touching web.xml does not cause the application context to restart. This appears to be true for a web application that is deployed within an expanded ear directory. However, touching the web.xml for an application deployed by itself (i.e. a web application directory directly under the deploy directory) does reload.

              Again, it seems like I can go through the motions of reloading a specific web application context through the JMX admin interface, but the classes are not reloading.

              Needless to say, but having to restart the server every time we want to update classes makes for a very painful development process. Does anyone have any specific information related to this?

              Thanks.

              Scott Sayles

              • 4. Re: how to restart a Jetty web app (so that it's classes are
                Scott Sayles Newbie

                Sorry for not responding earlier...

                Touching web.xml does not cause the context to reload. This appears to be the case for web apps which are packaged under an unpacked ear deployment. However, a web application deployed by itself (e.g. placed directly under the deploy directly) does reload.

                Again, reloading the application context via the Jetty JMX admin interface appears to go through the motions, but the classes are not reloading.

                Having to restart the server every time we want to update any of the classes makes for painful development process. Does anyone have any specific information about being able to do this?

                Thanks.

                Scott Sayles

                • 5. Re: how to restart a Jetty web app (so that it's classes are
                  Scott Sayles Newbie

                  (I've tried posting twice and I don't see anything on the page so I'm trying again. My apologies if this is another duplicate.)

                  Touching web.xml does not cause the context to reload. This appears to be the case for web apps which are packaged under an unpacked ear deployment. However, a web application deployed by itself (e.g. placed directly under the deploy directory) does reload.

                  Again, reloading the application context via the Jetty JMX admin interface appears to go through the motions, but the classes are not reloading.

                  Having to restart the server every time we want to update any of the classes makes for painful development process. Does anyone have any specific information about being able to do this?

                  Thanks.

                  Scott Sayles

                  • 6. Re: how to restart a Jetty web app (so that it's classes are
                    Julian Gosnell Expert

                    well then I guess the answer is:

                    Your deployable and reloadable granularity need to be the same.

                    If you just want to bounce the webapp separately, deploy it seperately during your development iteration.

                    JBoss DOES support reloading of entire apps - but you are prevented from doing this by this other piece of broken code that you are using.

                    If you want to know how to deploy a war to a specific context, take a look in:

                    http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jboss/contrib/jetty/FAQ?rev=HEAD&content-type=text/vnd.viewcvs-markup

                    I'm afraid that is the best I can do.


                    Jules

                    • 7. Re: how to restart a Jetty web app (so that it's classes are
                      Scott Sayles Newbie

                      Jules,

                      Thanks for your reply.

                      I've figured out a couple more things since then and I believe I have an answer now. I think my main problem was that I was incorrectly trying to cause the web application context to restart via the Jetty JMX MBean. This was due to my own ignorance of how things work. I've learned that I need to redeploy the web app using the main deployer. I've tried this in the JMX console and it seems to work fine.

                      Having to go through the JMX console for doing the redeploy is somewhat cumbersome but not so bad. However, I've learned of a JMX ant task that can perform the deploys for you via the main deployer MBean. Once I employ thin in our build we will have a *much* better development process (or at least a faster one).

                      Deploying a webapp seperately outside of an ear such that it can still access classes and EJBs in the ear is a viable option under JBoss 3.x. This was not so in JBoss 2.4, which was why I believed I needed to deploy my web app within the ear. However, if your web app has JNDI references (like ejb-ref or ejb-local-ref), will these work still if you deploy seperately from your ear? I've had the privilege of speaking with David Jencks about this and he thinks it would probably break. However, I haven't tried this.

                      I have also found that my web application startup in the current JBoss 3.0.1 branch is much faster (with Jetty). woohoo! Life is getting much easier now. ;)

                      Thanks.

                      Scott Sayles

                      • 8. Re: how to restart a Jetty web app (so that it's classes are
                        David Jencks Master

                        To be a little more specific, touching the dd of an embedded deployment won't do anything: only the top level dd is watched by the deployment scanner.

                        To redeploy an embedded package, call MainDeployer.redeploy with the (string rep) of the url of the package you wish to redeploy. You can do this through the web interface, the ant jmx task, or any other way of communicating with the jmx server you wish to use. I've only tried this with unpacked deployments, but if you have a packed deployment deployed directly through jmx (rather than the deployment scanner) and you update its contents with a new subpackage it might work on that also. (For instance, emacs seems to be able to edit the contents of jars directly).

                        • 9. Re: how to restart a Jetty web app (so that it's classes are
                          Julian Gosnell Expert


                          The ENC stuff is a good point..

                          I guess you should get onto www.sf.net, find the JBoss project and request that individual modules within an EAR can be bounced...

                          Trouble is - this is problematic, because if we assume an undeploy()...deploy(), then there is a period of time where the EAR is INVALID...

                          At some stage soon we should have an ATOMIC redeploy(), which would fit very nicely here.

                          This is a nice idea !

                          If I have 1000s of ejbs and a small, but intensively developed webapp that makes a lot of use of ENC, then this would make my life much easier...

                          One last thought - have you tried making your changes to your webapp's files, then finding the correspondong Jetty MBean and stop()/start()-ing the context. This would probably give you what you want and could be automated from your ant task as well....


                          Let me know if this works for you and we can put it in the FAQ.


                          Jules