Ulf Dittmer wrote:While there is sure to be an internal API for this (which would be used by the Tomcat Manager as well), standard web apps are not allowed access to Tomcat's internal classes. Setting the context to be privileged may help with that, but I'm not sure if it's sufficient.
Jeff Harbinson wrote:Hi folks.
Is there some internal tomcat API that allows starting a webapp from another webapp in the same tomcat instance, or is the only way to accomplish this is by sending HTTP requests to the tomcat manager?
Thanks!
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:There is already a webapp to do that. It's the Tomcat manager/admin webapp(s). And it's what you're invoking when you use the HTTP-based control interface.
Then again, you can probably use JMX. JSR-88 handles deployment, and I think also start/stop, and there's another JSR for general control, although I forget its number.
Jeff Harbinson wrote:
Tim Holloway wrote:There is already a webapp to do that. It's the Tomcat manager/admin webapp(s). And it's what you're invoking when you use the HTTP-based control interface.
Then again, you can probably use JMX. JSR-88 handles deployment, and I think also start/stop, and there's another JSR for general control, although I forget its number.
Ooh - JMX may be a good option. I wasn't aware that tomcat supported it.
To answer a previous question as to why I want to do this - I want to monitor another server. If that other server stops responding, I then want to start the local webapp.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:
You're probably better off just running a cluster unless you're really tight for resources. It takes time to launch a webapp. A cluster can fail over much faster.
Ulf Dittmer wrote:You wouldn't use the servlet (that's only for HTTP access) - you'd need to figure out the actual API calls (maybe starting with the embedding code I mentioned).
But the easiest way may indeed be to make an URLConnection from your web app to the Manager servlet.
Jeff Harbinson wrote:
Ulf Dittmer wrote:You wouldn't use the servlet (that's only for HTTP access) - you'd need to figure out the actual API calls (maybe starting with the embedding code I mentioned).
But the easiest way may indeed be to make an URLConnection from your web app to the Manager servlet.
For those of you familiar w/ these internal tomcat classes -
I'm looking at the Embedded class:
http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/catalina/startup/Embedded.html
Is there a more straight forward way to start a webapp, as opposed to the multiple steps mentioned in the javadoc? Ideally, I'd just be able to refer to a context already defined in server.xml and just ask tomcat to start it...
Thanks.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:
Jeff Harbinson wrote:
Ulf Dittmer wrote:You wouldn't use the servlet (that's only for HTTP access) - you'd need to figure out the actual API calls (maybe starting with the embedding code I mentioned).
But the easiest way may indeed be to make an URLConnection from your web app to the Manager servlet.
For those of you familiar w/ these internal tomcat classes -
I'm looking at the Embedded class:
http://tomcat.apache.org/tomcat-5.5-doc/catalina/docs/api/org/apache/catalina/startup/Embedded.html
Is there a more straight forward way to start a webapp, as opposed to the multiple steps mentioned in the javadoc? Ideally, I'd just be able to refer to a context already defined in server.xml and just ask tomcat to start it...
Thanks.
You shouldn't be placing application contexts in server.xml. That's been deprecated since about 1985. One reason being that the tomcat control can't manage individual webapps in server.xml. When server.xml gets modified, the entire Tomcat server has to be restarted.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:
JMX appears to be your best bet. Either directly or via the HTTP JMX proxy.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:The class name of an MBean is typically the same name as the class that it controls with "MBean" appended to the classname. However, the ObjecName that you see in jconsole should be all you need. For example: "Catalina:type=Manager,path=/servlets-examples,host=localhost"
Tim Holloway wrote:The class name of an MBean is typically the same name as the class that it controls with "MBean" appended to the classname. However, the ObjecName that you see in jconsole should be all you need. For example: "Catalina:type=Manager,path=/servlets-examples,host=localhost"
Consider Paul's rocket mass heater. |