You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Istvan Devai <is...@istvandevai.com> on 2013/05/04 18:15:25 UTC
proper context usage
Hi all,
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).
- 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). 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.
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?
- Or maybe deploy the app in a different way that retains the
app-specific context file?
- Any other solution to my problem in general?
I'm using Linux and Tomcat 7.0.37.
Kind regards,
Istvan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: proper context usage
Posted by Mark Thomas <ma...@apache.org>.
On 04/05/2013 17:15, Istvan Devai wrote:
> 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?
> - Or maybe deploy the app in a different way that retains the
> app-specific context file?
> - Any other solution to my problem in general?
>
> I'm using Linux and Tomcat 7.0.37.
There might be a bug here in the order resources are processed. Looking
at it - and documenting the expected behaviour - is still on my TODO list.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: proper context usage
Posted by "Mark H. Wood" <mw...@IUPUI.Edu>.
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.