You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Rob Gregory <Ro...@RosesGroup.co.uk> on 2006/02/24 20:52:05 UTC

[HELP] Forcing Context Reload (watched resource) via Java Code

Hi All

 

I'm using Tomcat 5.5.9 on Java 1.5.under mixed OS's. 

 

 

The question is one of forcing a context/webapp reload via java code - is
this possible? I know adding a watched resource or adding a new lib triggers
a reload (so hopefully to trigger this via code is possible).

 

We use a dedicated Tomcat per application so even if Tomcat had to be fully
restarted - this would help.

 

 

Basically I am writing out the JDBC details from within a servlet on startup
(which is fine) but by this time the datasources are already available (but
wrongly configured) so I need to force a reload with the correct details. I
appreciate this is a little big of a frig but I have tried every thing else
(Dynamic datasources, etc) but with a read-only Tomcat context I was unable
to bind them.

 

Any help or pointers are much appreciated.

 

Thanks in advance

Rob


Re: [HELP] Forcing Context Reload (watched resource) via Java Code

Posted by Glen Mazza <gr...@verizon.net>.
Martin Gainty wrote:

> Good Morning Rob-
> 
> Message Beans, Session Beans and Business Entity Beans need a J2EE 
> container take a look at Oracle App Server .. a good headsup is 
> available at
> http://www.oracle.com/oramag/oracle/02-jan/o12industry.html

I think the "MBeans"[1] refer to "Managed Beans", not "Message Beans", 
so Tomcat supports them--no app server should be needed here.

Glen

[1] http://tomcat.apache.org/tomcat-5.5-doc/mbeans-descriptor-howto.html


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


RE: [HELP] Forcing Context Reload (watched resource) via Java Code

Posted by Rob Gregory <Ro...@RosesGroup.co.uk>.
I would be looking for a Tomcat only resolution as I don't want to introduce
any more dependencies. I'm pretty sure this is possible with just Tomcat as
the html manager webapp is already doing the reloads.

Thanks anyway
Rob

-----Original Message-----
From: Martin Gainty [mailto:mgainty@hotmail.com] 
Sent: 26 February 2006 13:38
To: Tomcat Users List
Subject: Re: [HELP] Forcing Context Reload (watched resource) via Java Code

Good Morning Rob-

Message Beans, Session Beans and Business Entity Beans need a J2EE container

take a look at Oracle App Server .. a good headsup is available at
http://www.oracle.com/oramag/oracle/02-jan/o12industry.html
The J2ee authors work for Sun and have posted a very well written summary of

uses for J2EE containe thru SunOne AppServer at
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_
2e/deployment/deployment2.html

Keep us apprised,
Martin-

----- Original Message ----- 
From: "Rob Gregory" <Ro...@RosesGroup.co.uk>
To: "'Tomcat Users List'" <us...@tomcat.apache.org>
Sent: Sunday, February 26, 2006 7:37 AM
Subject: RE: [HELP] Forcing Context Reload (watched resource) via Java Code


> Thanks Glen,
>
> A new area for me to investigate.
>
> I appreciate this is not a common design but I am writing out the 
> datasource
> configuration details dynamically (which is working fine) and I need to
> reload Tomcat for these datasources to be setup as it's too late by the 
> time
> I have written them out. They only get re-written if any details such as
> password has changed.
>
> Thanks Again
> Rob
>
> -----Original Message-----
> From: Glen Mazza [mailto:grm7790@verizon.net]
> Sent: 25 February 2006 17:49
> To: Tomcat Users List
> Subject: Re: [HELP] Forcing Context Reload (watched resource) via Java 
> Code
>
> Rob Gregory wrote:
>
>> Thanks Glen for the suggestion.
>>
>> I was hoping for a more integrated approach without the need for
> additional
>> jars or external commands.
>>
>> Could I not just deploy may webapp with manager privileges and call the
>> reload internally? Would this be feasibly?
>>
>
> I think JMX / MBeans would be the technology you are looking for here,
> which Tomcat supports, but this is beyond my scope of knowledge.  As for
> a webapp being able to programatically reload itself, I am unsure, but
> such a design is probably rather uncommon.
>
> Glen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 

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


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


Re: [HELP] Forcing Context Reload (watched resource) via Java Code

Posted by Martin Gainty <mg...@hotmail.com>.
Good Morning Rob-

Message Beans, Session Beans and Business Entity Beans need a J2EE container 
take a look at Oracle App Server .. a good headsup is available at
http://www.oracle.com/oramag/oracle/02-jan/o12industry.html
The J2ee authors work for Sun and have posted a very well written summary of 
uses for J2EE containe thru SunOne AppServer at
http://java.sun.com/blueprints/guidelines/designing_enterprise_applications_2e/deployment/deployment2.html

Keep us apprised,
Martin-

----- Original Message ----- 
From: "Rob Gregory" <Ro...@RosesGroup.co.uk>
To: "'Tomcat Users List'" <us...@tomcat.apache.org>
Sent: Sunday, February 26, 2006 7:37 AM
Subject: RE: [HELP] Forcing Context Reload (watched resource) via Java Code


> Thanks Glen,
>
> A new area for me to investigate.
>
> I appreciate this is not a common design but I am writing out the 
> datasource
> configuration details dynamically (which is working fine) and I need to
> reload Tomcat for these datasources to be setup as it's too late by the 
> time
> I have written them out. They only get re-written if any details such as
> password has changed.
>
> Thanks Again
> Rob
>
> -----Original Message-----
> From: Glen Mazza [mailto:grm7790@verizon.net]
> Sent: 25 February 2006 17:49
> To: Tomcat Users List
> Subject: Re: [HELP] Forcing Context Reload (watched resource) via Java 
> Code
>
> Rob Gregory wrote:
>
>> Thanks Glen for the suggestion.
>>
>> I was hoping for a more integrated approach without the need for
> additional
>> jars or external commands.
>>
>> Could I not just deploy may webapp with manager privileges and call the
>> reload internally? Would this be feasibly?
>>
>
> I think JMX / MBeans would be the technology you are looking for here,
> which Tomcat supports, but this is beyond my scope of knowledge.  As for
> a webapp being able to programatically reload itself, I am unsure, but
> such a design is probably rather uncommon.
>
> Glen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
> 

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


RE: [HELP] Forcing Context Reload (watched resource) via Java Code

Posted by Rob Gregory <Ro...@RosesGroup.co.uk>.
Thanks Glen,

A new area for me to investigate.

I appreciate this is not a common design but I am writing out the datasource
configuration details dynamically (which is working fine) and I need to
reload Tomcat for these datasources to be setup as it's too late by the time
I have written them out. They only get re-written if any details such as
password has changed.

Thanks Again
Rob

-----Original Message-----
From: Glen Mazza [mailto:grm7790@verizon.net] 
Sent: 25 February 2006 17:49
To: Tomcat Users List
Subject: Re: [HELP] Forcing Context Reload (watched resource) via Java Code

Rob Gregory wrote:

> Thanks Glen for the suggestion.
> 
> I was hoping for a more integrated approach without the need for
additional
> jars or external commands. 
> 
> Could I not just deploy may webapp with manager privileges and call the
> reload internally? Would this be feasibly?
> 

I think JMX / MBeans would be the technology you are looking for here, 
which Tomcat supports, but this is beyond my scope of knowledge.  As for 
a webapp being able to programatically reload itself, I am unsure, but 
such a design is probably rather uncommon.

Glen

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


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


Re: [HELP] Forcing Context Reload (watched resource) via Java Code

Posted by Glen Mazza <gr...@verizon.net>.
Rob Gregory wrote:

> Thanks Glen for the suggestion.
> 
> I was hoping for a more integrated approach without the need for additional
> jars or external commands. 
> 
> Could I not just deploy may webapp with manager privileges and call the
> reload internally? Would this be feasibly?
> 

I think JMX / MBeans would be the technology you are looking for here, 
which Tomcat supports, but this is beyond my scope of knowledge.  As for 
a webapp being able to programatically reload itself, I am unsure, but 
such a design is probably rather uncommon.

Glen

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


RE: [HELP] Forcing Context Reload (watched resource) via Java Code

Posted by Rob Gregory <Ro...@RosesGroup.co.uk>.
Thanks Glen for the suggestion.

I was hoping for a more integrated approach without the need for additional
jars or external commands. 

Could I not just deploy may webapp with manager privileges and call the
reload internally? Would this be feasibly?

Thanks Again
Rob


-----Original Message-----
From: Glen Mazza [mailto:grm7790@verizon.net] 
Sent: 25 February 2006 03:01
To: Tomcat Users List
Subject: Re: [HELP] Forcing Context Reload (watched resource) via Java Code

Rob Gregory escribió:
> Hi All
> 
>  
> 
> I'm using Tomcat 5.5.9 on Java 1.5.under mixed OS's. 
> 
>  
> 
>  
> 
> The question is one of forcing a context/webapp reload via java code - is
> this possible? I know adding a watched resource or adding a new lib
triggers
> a reload (so hopefully to trigger this via code is possible).
> 

Could the Ant manager commands be an option (they have deploy, undeploy, 
etc., tasks) for you?

http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing%20Manag
er%20Commands%20With%20Ant

Glen

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


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


Re: [HELP] Forcing Context Reload (watched resource) via Java Code

Posted by Glen Mazza <gr...@verizon.net>.
Rob Gregory escribió:
> Hi All
> 
>  
> 
> I'm using Tomcat 5.5.9 on Java 1.5.under mixed OS's. 
> 
>  
> 
>  
> 
> The question is one of forcing a context/webapp reload via java code - is
> this possible? I know adding a watched resource or adding a new lib triggers
> a reload (so hopefully to trigger this via code is possible).
> 

Could the Ant manager commands be an option (they have deploy, undeploy, 
etc., tasks) for you?

http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing%20Manager%20Commands%20With%20Ant

Glen

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