Re: API call to reload Tomcat web application
Hi Thanks for the tip. While I am very grateful for your advice, I am not sure I like either of the approaches. I was hoping just to call a Tomcat API function directly from my web application. Is'nt there a method called restart() or something? JMX seems like overkill since I do not need to control the application remotely. The application doing the calling is the application that needs to be restarted itself. Any further ideas? Thanks Jamie Pid-2 wrote: jamieb wrote: Hi there I am busy implementing an auto update facility for a Tomcat web application. As part of the auto update process, the auto update code needs to unpack the changed class files and reload the Tomcat web application. I am aware that you can configure Tomcat to automatically reload the web application when class files are changed. I've decided against the use of this functionality for fear of unscheduled service disruption. My question: Is recommended way for a web application to apply an update to itself and restart itself? Is there an API call to reload the current Tomcat web application from within that application? If app auto-reload facilities are switched off, you should be able to replace WAR files safely*, and then use the built in JMX stuff to restart the webapp in question. (* If you're doing it from a remote location, be sure to send it to a safe directory /then/ do an internal copy to replace the file, rather than directly uploading to the target web app dir. Failed or slow uploads won't cause problems then.) You can also use the included Tomcat Ant tasks, I think, (see bin/catalina-tasks.xml) See also: http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html The Tomcat manager app uses JMX AFAIK, so you could examine the source code if you wanted to customise your own utility. p Much appreciate Jamie - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/API-call-to-reload-Tomcat-web-application-tp16065357p16092888.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: API call to reload Tomcat web application
jamieb wrote: Hi Thanks for the tip. While I am very grateful for your advice, I am not sure I like either of the approaches. I was hoping just to call a Tomcat API function directly from my web application. Tomcat provides an API, in the form of JMX. Is'nt there a method called restart() or something? I'm not aware of one, have you found one in the docs? JMX seems like overkill since I do not need to control the application remotely. The application doing the calling is the application that needs to be restarted itself. Any further ideas? You haven't elaborated on how you're connecting to the box, but a simple JMX app could be run from the command line, or another webapp on the same server. I'd suggest that you would be better off if a different app called the restart, as you'll never be able to recover (or notify afterwards) from a failure if the app itself is down. p Thanks Jamie Pid-2 wrote: jamieb wrote: Hi there I am busy implementing an auto update facility for a Tomcat web application. As part of the auto update process, the auto update code needs to unpack the changed class files and reload the Tomcat web application. I am aware that you can configure Tomcat to automatically reload the web application when class files are changed. I've decided against the use of this functionality for fear of unscheduled service disruption. My question: Is recommended way for a web application to apply an update to itself and restart itself? Is there an API call to reload the current Tomcat web application from within that application? If app auto-reload facilities are switched off, you should be able to replace WAR files safely*, and then use the built in JMX stuff to restart the webapp in question. (* If you're doing it from a remote location, be sure to send it to a safe directory /then/ do an internal copy to replace the file, rather than directly uploading to the target web app dir. Failed or slow uploads won't cause problems then.) You can also use the included Tomcat Ant tasks, I think, (see bin/catalina-tasks.xml) See also: http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html The Tomcat manager app uses JMX AFAIK, so you could examine the source code if you wanted to customise your own utility. p Much appreciate Jamie - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: API call to reload Tomcat web application
Hi There I had a look at Tomcat's Manager application the reload(..) function reveals a hint: .. Context context = (Context) host.findChild(path); .. context.reload(); This should do the trick? Any idea on how to get the tomcat context object... from ActionServlet or ModuleConfig objects...? I am not familar with Tomcat's object model. Many thanks Jamie /** * Reload the web application at the specified context path. * * @param writer Writer to render to * @param path Context path of the application to be restarted */ protected void reload(PrintWriter writer, String path) { if (debug = 1) log(restart: Reloading web application at ' + path + '); if ((path == null) || (!path.startsWith(/) path.equals())) { writer.println(sm.getString(managerServlet.invalidPath, RequestUtil.filter(path))); return; } String displayPath = path; if( path.equals(/) ) path = ; try { Context context = (Context) host.findChild(path); if (context == null) { writer.println(sm.getString (managerServlet.noContext, RequestUtil.filter(displayPath))); return; } // It isn't possible for the manager to reload itself if (context.getPath().equals(this.context.getPath())) { writer.println(sm.getString(managerServlet.noSelf)); return; } context.reload(); writer.println (sm.getString(managerServlet.reloaded, displayPath)); } catch (Throwable t) { log(ManagerServlet.reload[ + displayPath + ], t); writer.println(sm.getString(managerServlet.exception, t.toString())); } } Pid-2 wrote: jamieb wrote: Hi Thanks for the tip. While I am very grateful for your advice, I am not sure I like either of the approaches. I was hoping just to call a Tomcat API function directly from my web application. Tomcat provides an API, in the form of JMX. Is'nt there a method called restart() or something? I'm not aware of one, have you found one in the docs? JMX seems like overkill since I do not need to control the application remotely. The application doing the calling is the application that needs to be restarted itself. Any further ideas? You haven't elaborated on how you're connecting to the box, but a simple JMX app could be run from the command line, or another webapp on the same server. I'd suggest that you would be better off if a different app called the restart, as you'll never be able to recover (or notify afterwards) from a failure if the app itself is down. p Thanks Jamie Pid-2 wrote: jamieb wrote: Hi there I am busy implementing an auto update facility for a Tomcat web application. As part of the auto update process, the auto update code needs to unpack the changed class files and reload the Tomcat web application. I am aware that you can configure Tomcat to automatically reload the web application when class files are changed. I've decided against the use of this functionality for fear of unscheduled service disruption. My question: Is recommended way for a web application to apply an update to itself and restart itself? Is there an API call to reload the current Tomcat web application from within that application? If app auto-reload facilities are switched off, you should be able to replace WAR files safely*, and then use the built in JMX stuff to restart the webapp in question. (* If you're doing it from a remote location, be sure to send it to a safe directory /then/ do an internal copy to replace the file, rather than directly uploading to the target web app dir. Failed or slow uploads won't cause problems then.) You can also use the included Tomcat Ant tasks, I think, (see bin/catalina-tasks.xml) See also: http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html The Tomcat manager app uses JMX AFAIK, so you could examine the source code if you wanted to customise your own utility. p Much appreciate Jamie - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context:
Re: API call to reload Tomcat web application
Sorry I didn't mean to say ActionServlet or ModuleConfig objects...these are struts based objects.. more generally, from within a Tomcat web application... how do you access the Context object? Thanks Jamie jamieb wrote: Hi There I had a look at Tomcat's Manager application the reload(..) function reveals a hint: .. Context context = (Context) host.findChild(path); .. context.reload(); This should do the trick? Any idea on how to get the tomcat context object... from ActionServlet or ModuleConfig objects...? I am not familar with Tomcat's object model. Many thanks Jamie /** * Reload the web application at the specified context path. * * @param writer Writer to render to * @param path Context path of the application to be restarted */ protected void reload(PrintWriter writer, String path) { if (debug = 1) log(restart: Reloading web application at ' + path + '); if ((path == null) || (!path.startsWith(/) path.equals())) { writer.println(sm.getString(managerServlet.invalidPath, RequestUtil.filter(path))); return; } String displayPath = path; if( path.equals(/) ) path = ; try { Context context = (Context) host.findChild(path); if (context == null) { writer.println(sm.getString (managerServlet.noContext, RequestUtil.filter(displayPath))); return; } // It isn't possible for the manager to reload itself if (context.getPath().equals(this.context.getPath())) { writer.println(sm.getString(managerServlet.noSelf)); return; } context.reload(); writer.println (sm.getString(managerServlet.reloaded, displayPath)); } catch (Throwable t) { log(ManagerServlet.reload[ + displayPath + ], t); writer.println(sm.getString(managerServlet.exception, t.toString())); } } Pid-2 wrote: jamieb wrote: Hi Thanks for the tip. While I am very grateful for your advice, I am not sure I like either of the approaches. I was hoping just to call a Tomcat API function directly from my web application. Tomcat provides an API, in the form of JMX. Is'nt there a method called restart() or something? I'm not aware of one, have you found one in the docs? JMX seems like overkill since I do not need to control the application remotely. The application doing the calling is the application that needs to be restarted itself. Any further ideas? You haven't elaborated on how you're connecting to the box, but a simple JMX app could be run from the command line, or another webapp on the same server. I'd suggest that you would be better off if a different app called the restart, as you'll never be able to recover (or notify afterwards) from a failure if the app itself is down. p Thanks Jamie Pid-2 wrote: jamieb wrote: Hi there I am busy implementing an auto update facility for a Tomcat web application. As part of the auto update process, the auto update code needs to unpack the changed class files and reload the Tomcat web application. I am aware that you can configure Tomcat to automatically reload the web application when class files are changed. I've decided against the use of this functionality for fear of unscheduled service disruption. My question: Is recommended way for a web application to apply an update to itself and restart itself? Is there an API call to reload the current Tomcat web application from within that application? If app auto-reload facilities are switched off, you should be able to replace WAR files safely*, and then use the built in JMX stuff to restart the webapp in question. (* If you're doing it from a remote location, be sure to send it to a safe directory /then/ do an internal copy to replace the file, rather than directly uploading to the target web app dir. Failed or slow uploads won't cause problems then.) You can also use the included Tomcat Ant tasks, I think, (see bin/catalina-tasks.xml) See also: http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html The Tomcat manager app uses JMX AFAIK, so you could examine the source code if you wanted to customise your own utility. p Much appreciate Jamie - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: API call to reload Tomcat web application
jamieb wrote: Hi there I am busy implementing an auto update facility for a Tomcat web application. As part of the auto update process, the auto update code needs to unpack the changed class files and reload the Tomcat web application. I am aware that you can configure Tomcat to automatically reload the web application when class files are changed. I've decided against the use of this functionality for fear of unscheduled service disruption. My question: Is recommended way for a web application to apply an update to itself and restart itself? Is there an API call to reload the current Tomcat web application from within that application? If app auto-reload facilities are switched off, you should be able to replace WAR files safely*, and then use the built in JMX stuff to restart the webapp in question. (* If you're doing it from a remote location, be sure to send it to a safe directory /then/ do an internal copy to replace the file, rather than directly uploading to the target web app dir. Failed or slow uploads won't cause problems then.) You can also use the included Tomcat Ant tasks, I think, (see bin/catalina-tasks.xml) See also: http://tomcat.apache.org/tomcat-6.0-doc/monitoring.html http://tomcat.apache.org/tomcat-6.0-doc/mbeans-descriptor-howto.html The Tomcat manager app uses JMX AFAIK, so you could examine the source code if you wanted to customise your own utility. p Much appreciate Jamie - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: API call to reload Tomcat web application
Jamie- yes there is a way if you register SimpletonAgent in the registry as a Managed Bean http://java.sun.com/developer/technicalArticles/J2SE/jmx.html perhaps if you have a simple test webapp we could suggest a test harness? Martin- - Original Message - From: jamieb [EMAIL PROTECTED] To: users@tomcat.apache.org Sent: Saturday, March 15, 2008 2:21 AM Subject: API call to reload Tomcat web application Hi there I am busy implementing an auto update facility for a Tomcat web application. As part of the auto update process, the auto update code needs to unpack the changed class files and reload the Tomcat web application. I am aware that you can configure Tomcat to automatically reload the web application when class files are changed. I've decided against the use of this functionality for fear of unscheduled service disruption. My question: Is recommended way for a web application to apply an update to itself and restart itself? Is there an API call to reload the current Tomcat web application from within that application? Much appreciate Jamie -- View this message in context: http://www.nabble.com/API-call-to-reload-Tomcat-web-application-tp16065357p1 6065357.html Sent from the Tomcat - User mailing list archive at Nabble.com. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]