You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by chuanjiang lo <lo...@gmail.com> on 2006/12/05 20:58:12 UTC

Webapp with Adminstrative Console

I am having a web application that have some config files(.ini) that
contains some settings so that during runtime the servlet would take the
settings from the config file and perform some action.

Together with the web application, there is an adminstrator console that
allows user to change the settings of the config file . I realize that if
the config file is changed, i would need to restart Tomcat as such my
servlet would read in the changed settings.

So i would need to have a button in my adminstrator console to restart
Tomcat. How could i issue the command to Tomcat to restart itself and what
is the best practice of doing this?

Appreciate any advice.

RE: Webapp with Adminstrative Console

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: chuanjiang lo [mailto:lochuanjiang@gmail.com] 
> Subject: Re: Webapp with Adminstrative Console
> 
> Looks like the <WatchedResource> tag is the easiest solution 
> of all but JMX seems interesting and i can learn something
> new but is it possible to do without Spring?

Yes, Tomcat uses JMX internally to manage itself.  Look at the source
code for the admin app, for example.  Looking at the LambdaProbe code
might be another way to learn how it's used with Tomcat.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Webapp with Adminstrative Console

Posted by chuanjiang lo <lo...@gmail.com>.
On 12/6/06, Mikolaj Rydzewski <mi...@ceti.pl> wrote:

> You could also use JMX to change configuration at runtime. Spring has
> nice JMX support.


Looks like the <WatchedResource> tag is the easiest solution of all but JMX
seems interesting and i can learn something new but is it possible to do
without Spring?

Re: Webapp with Adminstrative Console

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
chuanjiang lo wrote:
> I am having a web application that have some config files(.ini) that
> contains some settings so that during runtime the servlet would take the
> settings from the config file and perform some action.
>
> Together with the web application, there is an adminstrator console that
> allows user to change the settings of the config file . I realize that if
> the config file is changed, i would need to restart Tomcat as such my
> servlet would read in the changed settings.
I'd redesign the app. Of course you'll need time and source code for 
this ;-)

Since you're using a servlet to read config files, just map it to some 
URL and call it to reload configuration.

You could also use JMX to change configuration at runtime. Spring has 
nice JMX support.


-- 
Mikolaj Rydzewski      <mi...@ceti.pl>        http://ceti.pl/~miki/
                    PGP KeyID: 8b12ab02
There are three kinds of people: men, women and unix.


RE: Webapp with Adminstrative Console

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: chuanjiang lo [mailto:lochuanjiang@gmail.com] 
> Subject: Re: Webapp with Adminstrative Console
> 
> Is there any articles i can look at to implement the servlet watch for
> changes to the .ini file?

You can set a <WatchedResource> tag inside the <Context> element for
your webapp; changing the target of that should trigger a reload of the
app.  Look here for doc:
http://tomcat.apache.org/tomcat-5.5-doc/config/context.html#Nested%20Com
ponents

> I don't think i am able to redeploy the app, since the 
> adminstrator console changing the .ini file of the
> application that is currently running on tomcat..

Should be able to do it by sending a delayed refresh of the console page
back to the client, and also forwarding a request to the html-manager
app to do the redeploy.  A bit of a kludge, but it can probably be made
to work.  Shouldn't be needed with <WatchedResource>.

But better just to process the updated .ini file without redeploying the
app, if possible.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Webapp with Adminstrative Console

Posted by chuanjiang lo <lo...@gmail.com>.
On 12/6/06, Caldarale, Charles R <Ch...@unisys.com> wrote:

> Rather than restarting Tomcat, why don't you have the servlet watch for
> changes to the .ini file and reload it as needed?  Seems a bit of
> overkill to take the whole server down for just that.  You could also
> just redeploy the app when needed, which can be accomplished
> programmatically or via the Tomcat manager or html-manager webapps.



Is there any articles i can look at to implement the servlet watch for
changes to the .ini file?

I don't think i am able to redeploy the app, since the adminstrator console
changing the .ini file of the application that is currently running on
tomcat..

appreciate your advice :)

RE: Webapp with Adminstrative Console

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: chuanjiang lo [mailto:lochuanjiang@gmail.com] 
> Subject: Webapp with Adminstrative Console
> 
> I realize that if the config file is changed, i would
> need to restart Tomcat as such my servlet would read
> in the changed settings.

Rather than restarting Tomcat, why don't you have the servlet watch for
changes to the .ini file and reload it as needed?  Seems a bit of
overkill to take the whole server down for just that.  You could also
just redeploy the app when needed, which can be accomplished
programmatically or via the Tomcat manager or html-manager webapps.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org