tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark H. Wood" <mw...@IUPUI.Edu>
Subject Re: proper context usage
Date Mon, 06 May 2013 16:08:08 GMT
On Sat, May 04, 2013 at 06:15:25PM +0200, Istvan Devai wrote:
> My problem is, that I'd like to configure a valve for only one deployed 
> application (deployed as a .war file)
> 
> Here are the ways I've already tried:
> 
> - Putting the <Context> element into server.xml. This works, however, 
> after doing this, the manager application won't let me redeploy the 
> application (gives an error message describing this).

Usually not the best way.

> - Putting the valve declaration into conf/context.xml. This also works, 
> however, this way the valve configured for all deployed applications, 
> which is not possible in my case (the valve is doing authentication 
> stuff, which I do not want to take effect for other apps, eg the manager 
> app)
> - Putting the valve declaration into conf/Catalina/localhost/myapp.xml. 
> This also works fine, however this file is always deleted after 
> redeployment (as far as I know, this was introduced to tomcat 7, as 
> autoDeploy=false does not disable the deletion of context files).

It sounds as though you are placing the app. into the appBase
directory.  Put it somewhere else and declare docBase=path-to-your-app
and you should not have this problem anymore.  I use this pattern
extensively.

> The official solution to this, - according to the manual - is to put the
> context.xml file into the .war file itself. However, the problem with 
> this, is that the context contains database connections, mail sessions, 
> etc. that are different for every environment where the .war file is 
> deployed. That's why I'd like to stick with an external way of 
> configuration.

Exactly why I have always been puzzled as to why one would ever want
to place a context descriptor (which is most likely external
information unique to a single instance) inside a webapp.

> Questions:
> - Any idea how to have an external, application specific (that is, 
> non-shared) context file that is not deleted on redeployment in the manager?

See above.

> - Or maybe deploy the app in a different way that retains the 
> app-specific context file?

None that I could ever discover.  When an app. is placed in appBase,
Tomcat feels free to extract its own context descriptor and destroy
same as needed.  It can't tell our hand-built ones from its own
extracts.

-- 
Mark H. Wood, Lead System Programmer   mwood@IUPUI.Edu
Machines should not be friendly.  Machines should be obedient.

Mime
View raw message