You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jose María Zaragoza <de...@gmail.com> on 2013/12/17 11:33:09 UTC

Modify content in META-INF/context.xml

Hello:

I'm using Apache Tomcat 6.0.24 and I've deployed a web application
that defines its resources into META-INF/context.xml , especially
information about connection pool

Sometimes I''ve to edit that file to change some data , i.e, database's JDBC url

I've seen that restart web application is not enough to apply these
changes  , so I need to redeploy the web application ( I mean, unpack
WAR file, modify it , repack it again, copy to deploy folder ...)

My question:

Do you know other way to modify META-INF/context.xml and apply the
changes and don't have to redeploy the WAR file ?

Restart the web application is not a problem, but restart Tomcat is

Any ideas ?

Thanks and regards

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


Re: Modify content in META-INF/context.xml

Posted by Jose María Zaragoza <de...@gmail.com>.
2013/12/18 Jeffrey Janner <Je...@polydyne.com>:

> I think that at 6.x you need to do one of the following to the context.xml file located in the configBase ($CATALINA_BASE/conf/[enginename]/[hostname]/):
> 1. make the changes to the file there and reload the webapp
> 2. make the changes in the META_INF file and copy it to the configBase, then reload the webapp
> 3. delete the file from the configBase, then redeploy the webapp.
>
> With 7.x (at least the latest version) you get the copyXML paramter in the <Host> element which will give you more control over the process.
> Jeff


Hello Jeffrey:

Thanks a lot. You're right in all the points
I was testing all this options yesterday and I would like feedbak the
results to the list , but you did it before than me

Finally, my choice is the 3º option

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


RE: Modify content in META-INF/context.xml

Posted by Jeffrey Janner <Je...@PolyDyne.com>.

> -----Original Message-----
> From: Jose María Zaragoza [mailto:demablogia@gmail.com]
> Sent: Tuesday, December 17, 2013 4:33 AM
> To: Tomcat Users List
> Subject: Modify content in META-INF/context.xml
> 
> Hello:
> 
> I'm using Apache Tomcat 6.0.24 and I've deployed a web application that
> defines its resources into META-INF/context.xml , especially
> information about connection pool
> 
> Sometimes I''ve to edit that file to change some data , i.e, database's
> JDBC url
> 
> I've seen that restart web application is not enough to apply these
> changes  , so I need to redeploy the web application ( I mean, unpack
> WAR file, modify it , repack it again, copy to deploy folder ...)
> 
> My question:
> 
> Do you know other way to modify META-INF/context.xml and apply the
> changes and don't have to redeploy the WAR file ?
> 
> Restart the web application is not a problem, but restart Tomcat is
> 
> Any ideas ?
> 
> Thanks and regards

I think that at 6.x you need to do one of the following to the context.xml file located in the configBase ($CATALINA_BASE/conf/[enginename]/[hostname]/):
1. make the changes to the file there and reload the webapp
2. make the changes in the META_INF file and copy it to the configBase, then reload the webapp
3. delete the file from the configBase, then redeploy the webapp.

With 7.x (at least the latest version) you get the copyXML paramter in the <Host> element which will give you more control over the process.
Jeff


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


Re: Modify content in META-INF/context.xml

Posted by Jesse Barnum <js...@360works.com>.
> 
> Automatic deployment has had a bit of an overhaul in Tomcat 8 and those
> changes have been back-ported to 7.0.x for the next release. The
> behaviour in a number of edge cases is now clearly defined:
> http://ci.apache.org/projects/tomcat/tomcat8/docs/config/automatic-deployment.html

Yay! Thank you Mark, this is what I've been hoping for every since this behavior changed from 6 -> 7. This is great news for those of us that deploy commercial applications, and need an easy way for end user admins to modify an XML file to customize application behavior (and keep those customizations when new versions ship).


--Jesse Barnum, President, 360Works
http://www.360works.com
Product updates and news on http://facebook.com/360Works
(770) 234-9293
== Don't lose your data! http://360works.com/safetynet/ for FileMaker Server ==
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Modify content in META-INF/context.xml

Posted by Jose María Zaragoza <de...@gmail.com>.
> Automatic deployment has had a bit of an overhaul in Tomcat 8 and those changes have been back-ported to 7.0.x for the next release. The behaviour in a number of edge cases is now clearly defined:
> http://ci.apache.org/projects/tomcat/tomcat8/docs/config/automatic-deployment.html
>
> In your case, you'd want to deploy as a WAR with unpackWARs set to true.
> Then, any time you edit the META-INF/context.xml in the unpacked directory the web application will be redeployed using the new context.xml
>
> This might work with 6 but I can't remember (it is a long time since I looked at the 6.0.x automatic deployment code).
>
> ---------------------------------
>
>
> I'm on 6.0.26 and have this setting in my conf/server.xml file.
>
>       <Host name="localhost"  appBase="webapps"
>             unpackWARs="true" autoDeploy="true"
>             xmlValidation="false" xmlNamespaceAware="false">
>
>
> I was thinking it handled this kind of thing, but I may be wrong.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org




Thanks

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


RE: Modify content in META-INF/context.xml

Posted by "Propes, Barry L " <ba...@citi.com>.

-----Original Message-----
From: Mark Thomas [mailto:markt@apache.org] 
Sent: Tuesday, December 17, 2013 5:27 AM
To: Tomcat Users List
Subject: Re: Modify content in META-INF/context.xml

On 17/12/2013 11:16, Jose María Zaragoza wrote:
> 2013/12/17 André Warnier <aw...@ice-sa.com>:
>> Hi.
>> Without having any idea really of the precise mechanism behind 
>> database connections, I can still imagine that with the possibility 
>> of pooled connections to said database(s), it may be difficult to 
>> detect such a change in the corresponding context.xml and apply them 
>> "on the fly". Even more so if such connections could be shared between different applications.
> 
> 
> Thanks, but I didn't said that I neeed to apply changes "on the fly".
> Indeed, I said "Restart the web application is not a problem"
> 
> I only wan't to have to redeploy the web application to modify 
> META-INF/context.xml and apply changes.

How do you feel about a Tomcat upgrade?

Automatic deployment has had a bit of an overhaul in Tomcat 8 and those changes have been back-ported to 7.0.x for the next release. The behaviour in a number of edge cases is now clearly defined:
http://ci.apache.org/projects/tomcat/tomcat8/docs/config/automatic-deployment.html

In your case, you'd want to deploy as a WAR with unpackWARs set to true.
Then, any time you edit the META-INF/context.xml in the unpacked directory the web application will be redeployed using the new context.xml

This might work with 6 but I can't remember (it is a long time since I looked at the 6.0.x automatic deployment code).

Mark
---------------------------------


I'm on 6.0.26 and have this setting in my conf/server.xml file.

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false">


I was thinking it handled this kind of thing, but I may be wrong. 

---------------------------------------------------------------------
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: [Slightly OT] Modify content in META-INF/context.xml

Posted by Mark Thomas <ma...@apache.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 19/12/2013 14:58, Christopher Schultz wrote:
> My experience has been that, specifically with JNDI resources, the 
> resource is not touched during the reload procedure. So, for
> instance, if the JNDI name doesn't change but the URL does, the
> application does in fact require a re-deployment. Is that
> intentional behavior, or just a result of the implementation we
> happen to currently have?

You need to be very clear whether you are talking about a reload or a
redploy. You also need to specific about the Tomcat version as much of
the recent work was around cleaning up many of the ambiguities that
exist is most versions in use today.

In summary, a reload:
- - calls stop() then start() on the same Context object
- - re-reads web.xml
- - doesn't re-read context.xml
- - is triggered by a change in web.xml, from the Manager app or via JMX
- - can also be triggered by a change in a reload resource

whereas a redploy:
- - calls stop() then destroy on the current context
- - re-reads context.xml and creates a new context object
- - is triggered by a change in context.xml, WAR file or DIR (timestamps)
- - can also be triggered by a change in a redeploy resource

Looking at JNDI and reloading:
- - the Context keeps the same NamingContextListener
- - the NamingContext is renewed
- - the NamingResources has stop()/start() called
- - NamingResources.stop() should close any resources that can be closed

> Is it reasonable to modify Tomcat such that the JNDI resource is 
> disposed and re-built during an application reload?

This should be what happens although a fair amount of information is
retained.

> Of course, this would only make sense for resources defined in a
> webapp's Context/Resource, not for global resources. This would
> also make it possible to package JDBC drivers along with the web
> application and not cause ClassLoader pinning.

Class loaders should not be pinned if correctly used.

> If the above change were made, a redeployment would not be
> completely necessary, even if it does turn out to be the best
> solution.

If a URL (or any other config of a JNDI resource) changes then that is
a change in context.xml and that has to result in a redeployment.
Trying to figure out if a change in context.xml should trigger a
redeploy or a reload is just far too error prone.

Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJSs0GjAAoJEBDAHFovYFnnEFcQALKczvkUtVgmF/4g5Z44buEM
jMftq/pWiis0ks64dzzictVkOY3L8r9F1YpqWzDcTceJHBT4QCdaD2koNSDu7lvc
4EZuiLA+SfyucmWrS/G1v8u7Mqufkli/ba2Y9s7WF+j74So+46qDzT5SNwGErgGa
yzvrqG81U3am1iXcAfyEkQlUllYIbRQNaV1axLeKKX8jL61v85v8z5c8B9svEXit
HYQKFp+S+b5Azxlv45CDF6X/xPjoH7dbb1zAe1JVIgJ3b8Q8m5cPspV5zXZa0JwM
gB/B92PMTT/vswpgPQXLkiSfnTzzj6smoaPKPC1qRStyyr19OY0I5J9nhLldQ63j
mRlvvIU8oXN9CHAvCvRUJ2boindIRu30JfOU1tkGF+09sAnPgRexz/B3KaMmBqVJ
L14DyHJF+ylapodmOH33m0RXzg5NYOH9ZjpYQfKEZAJ9IUTX6Mpr+N8kmwdNriWh
q6aj0WmBdHRb8AyaFzTLggdtS90CAFRPsrR3kSwOwJ03w7aU0xUysDdTBiMxz9cQ
EBAVtX7bBCLUsSvJDJi8ymNr3p92+yDZ+64IXBS/Dnjeaza+2vfxvRL7h/rr3cbg
5bzkZgzQl9KHaw9y1g4Lwnl55p5y+TsQt9rdZpdwQZxhaU4uAAfHPWj46RyHq+09
3hxHhSYsFsQPTlQyQrKl
=B8fV
-----END PGP SIGNATURE-----

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


Re: [Slightly OT] Modify content in META-INF/context.xml

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 12/17/13, 6:27 AM, Mark Thomas wrote:
> On 17/12/2013 11:16, Jose María Zaragoza wrote:
>> 2013/12/17 André Warnier <aw...@ice-sa.com>:
>>> Hi. Without having any idea really of the precise mechanism
>>> behind database connections, I can still imagine that with the
>>> possibility of pooled connections to said database(s), it may
>>> be difficult to detect such a change in the corresponding
>>> context.xml and apply them "on the fly". Even more so if such
>>> connections could be shared between different applications.
>> 
>> 
>> Thanks, but I didn't said that I neeed to apply changes "on the
>> fly". Indeed, I said "Restart the web application is not a
>> problem"
>> 
>> I only wan't to have to redeploy the web application to modify 
>> META-INF/context.xml and apply changes.
> 
> How do you feel about a Tomcat upgrade?
> 
> Automatic deployment has had a bit of an overhaul in Tomcat 8 and
> those changes have been back-ported to 7.0.x for the next release.
> The behaviour in a number of edge cases is now clearly defined: 
> http://ci.apache.org/projects/tomcat/tomcat8/docs/config/automatic-deployment.html
>
>  In your case, you'd want to deploy as a WAR with unpackWARs set to
> true. Then, any time you edit the META-INF/context.xml in the
> unpacked directory the web application will be redeployed using the
> new context.xml
> 
> This might work with 6 but I can't remember (it is a long time
> since I looked at the 6.0.x automatic deployment code).

My experience has been that, specifically with JNDI resources, the
resource is not touched during the reload procedure. So, for instance,
if the JNDI name doesn't change but the URL does, the application does
in fact require a re-deployment. Is that intentional behavior, or just
a result of the implementation we happen to currently have?

Is it reasonable to modify Tomcat such that the JNDI resource is
disposed and re-built during an application reload? Of course, this
would only make sense for resources defined in a webapp's
Context/Resource, not for global resources. This would also make it
possible to package JDBC drivers along with the web application and
not cause ClassLoader pinning.

If the above change were made, a redeployment would not be completely
necessary, even if it does turn out to be the best solution.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJSswmdAAoJEBzwKT+lPKRYdDoP/06VSHikoitoKKIRG1tVdFne
EBKJBF9VtZeHlOkPlCpbrYVOHEgmOs8cci3/0FbWhfooxIU7GwZfKO1Ry2vC/WD3
U/jNpzLqa67VU9iTBk8NYku2Bj0NPlVtEpdGgihZNKEN8Z6JyHuk0H/q0XuYs7/k
BlKq/csPHaWNG607PKlPJlWuHgRKeh37iFXdzwB3//HeUP/b/vtF8iS9ZuqtKpTo
VObyseuX8dat9VrAjxsh5A5w0Ly6M9y3JF2vb6rlf8+55jEN/xcMCELdUx4pPoEu
RA4q4EhMNdkLBIn/AUuyCXTHF2kcVRH8dqhBH9AsU5XrZRzGS7r/BiRd3YfaKqqN
aP8Te2JJSMrWZbJ3E2m+akv542+JSwXBtLMT+SvvWSQHLqWUkYcmPcIOd9Ht5ARQ
FRV8TUUjJA8gNXBA1lUm0UJJxzzX2BsvidLWhos0FHN0/Rb5Guj+Tdp8iAJorPWb
gOnjxJYWMyDz3xL7s9cBr8hRTcqI/eqzF2HGAr2vPqY//29P6329T4SKq3GZ1EIn
qpy7Hej/kYP/edSkPAbi3Jhy0Hw88pLzKWek3DfxY3x8ABbUSUM+M1nCGBcuFGrJ
LwwxQPgqh1uGvMGHU2CooZBE7wiajHAm7Nq9oIy6jm+Ho//tg+F1o9orgpzPTvsZ
Vl7FApejtEzftQ4R5cRz
=uYBw
-----END PGP SIGNATURE-----

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


Re: Modify content in META-INF/context.xml

Posted by Mark Thomas <ma...@apache.org>.
On 17/12/2013 11:16, Jose María Zaragoza wrote:
> 2013/12/17 André Warnier <aw...@ice-sa.com>:
>> Hi.
>> Without having any idea really of the precise mechanism behind database
>> connections, I can still imagine that with the possibility of pooled
>> connections to said database(s), it may be difficult to detect such a change
>> in the corresponding context.xml and apply them "on the fly". Even more so
>> if such connections could be shared between different applications.
> 
> 
> Thanks, but I didn't said that I neeed to apply changes "on the fly".
> Indeed, I said "Restart the web application is not a problem"
> 
> I only wan't to have to redeploy the web application to modify
> META-INF/context.xml and apply changes.

How do you feel about a Tomcat upgrade?

Automatic deployment has had a bit of an overhaul in Tomcat 8 and those
changes have been back-ported to 7.0.x for the next release. The
behaviour in a number of edge cases is now clearly defined:
http://ci.apache.org/projects/tomcat/tomcat8/docs/config/automatic-deployment.html

In your case, you'd want to deploy as a WAR with unpackWARs set to true.
Then, any time you edit the META-INF/context.xml in the unpacked
directory the web application will be redeployed using the new context.xml

This might work with 6 but I can't remember (it is a long time since I
looked at the 6.0.x automatic deployment code).

Mark


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


Re: Modify content in META-INF/context.xml

Posted by Jose María Zaragoza <de...@gmail.com>.
2013/12/17 André Warnier <aw...@ice-sa.com>:
> Hi.
> Without having any idea really of the precise mechanism behind database
> connections, I can still imagine that with the possibility of pooled
> connections to said database(s), it may be difficult to detect such a change
> in the corresponding context.xml and apply them "on the fly". Even more so
> if such connections could be shared between different applications.


Thanks, but I didn't said that I neeed to apply changes "on the fly".
Indeed, I said "Restart the web application is not a problem"

I only wan't to have to redeploy the web application to modify
META-INF/context.xml and apply changes.


Regards

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


Re: Modify content in META-INF/context.xml

Posted by André Warnier <aw...@ice-sa.com>.
Jose María Zaragoza wrote:
> Hello:
> 
> I'm using Apache Tomcat 6.0.24 and I've deployed a web application
> that defines its resources into META-INF/context.xml , especially
> information about connection pool
> 
> Sometimes I''ve to edit that file to change some data , i.e, database's JDBC url
> 
> I've seen that restart web application is not enough to apply these
> changes  , so I need to redeploy the web application ( I mean, unpack
> WAR file, modify it , repack it again, copy to deploy folder ...)
> 
> My question:
> 
> Do you know other way to modify META-INF/context.xml and apply the
> changes and don't have to redeploy the WAR file ?
> 
> Restart the web application is not a problem, but restart Tomcat is
> 
> Any ideas ?
> 

Hi.
Without having any idea really of the precise mechanism behind database connections, I can 
still imagine that with the possibility of pooled connections to said database(s), it may 
be difficult to detect such a change in the corresponding context.xml and apply them "on 
the fly". Even more so if such connections could be shared between different applications.


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