0

(Tomcat discussed here is an in-Liferay embedded 7.0.42.)

For WARs that come with no META-INF\context.xml Tomcat supplies its own. Hence whenever I re-deploy such app this file also gets (re)written. Unfortunately the default version of META-INF/context.xml does not suit my (debugging) needs.

Where does Tomcat store the default version of META-INF\context.xml?

Possibly an alternate solution?
I also tried to place my own context.xml here, so Tomcat does not supply its own:

%TOMCAT%\conf\Catalina\localhost\mywebapp.xml

...without any apparent effect; context.xml in webapps\my-web-app\META-INF\context.xml still gets (over)written with Tomcat's own.

(Modifying the WAR itself is not desirable.)

Jaroslav Záruba
  • 4,694
  • 5
  • 39
  • 58
  • 1
    "For WARs that come with no META-INF\context.xml Tomcat supplies its own." Where do you get this information? Citation please. And where does it say that it's stored anywhere? – user207421 Mar 07 '16 at 08:45
  • I am witnessing it. I deploy a WAR without it, when Tomcat unpacks the WAR it now has META-INF/context.xml. At first I suspected it is the Liferay doing it, but I couldn't find anything in its files. Now when you are asking this defensively it makes me rethink... Maybe it's Liferay doing it after all. – Jaroslav Záruba Mar 07 '16 at 09:27
  • OK, so we can accept that it's Tomcat that's doing it, but you've found where it's stored; so what's the question? – user207421 Mar 07 '16 at 11:25
  • Well, I haven't. :( And since I asked this question I went through some posts mentioning that older versions of Liferay (not mine) were overwriting this file even when it was present in the WAR. So in the end you might have been right that it is not Tomcat but Liferay who supplies the file. Still looking into it. Maybe I should re-phrase my question, rename it or just delete and ask again. (I failed when trying to find out where Liferay gets its default context.xml.) – Jaroslav Záruba Mar 07 '16 at 14:14
  • Liferay does not have any stakes in tomcat's context.xml that I'm aware of. You might want to inject your own META-INF/context.xml *before* you deploy the webapp to Liferay (or tomcat) in order to keep it. Also, you can make Liferay deploy to a different directory than `webapps` and point to *that* directory from your own `conf/Catalina/localhost/whatever.xml` – Olaf Kock Mar 07 '16 at 20:35
  • @OlafKock It appears that Liferay actually does play with it at times: https://issues.liferay.com/browse/LPS-29750 – Jaroslav Záruba Mar 08 '16 at 07:28
  • ok, I stand corrected - there are references to context.xml in Liferay's source code (now I aware of them) Your best bet might be to not rely on Liferay's deployment then, or to modify the WAR, even though you think it's not desirable. – Olaf Kock Mar 08 '16 at 08:30

1 Answers1

0

This is how one can supply one's own context.xml ad-hoc, during the build (i.e. w/o modifying the sources) and thus avoid Tomcat adding its own:
mvn install ... -Dmaven.war.containerConfigXML=src/main/resources/context.xml

Jaroslav Záruba
  • 4,694
  • 5
  • 39
  • 58