What is the correct META-INF directory location for context.xml in Tomcat?
Asked Answered
A

1

15

Should a "context.xml" file for deploying application-specific configuration to Tomcat be placed in:

src/main/resources/META-INF/context.xml

...or...

src/main/webapp/META-INF/context.xml ?

Justification for asking: Have seen conflicting advice on StackOverflow and could not find the specific location mentioned in the Tomcat documentation.

Acme answered 27/10, 2014 at 10:27 Comment(1)
I think WebContent/META-INF/context.xml is the right placeReorientation
B
17

The documentation is indeed not specific about this.

It is src/main/webapp/META-INF since the file needs to end up deployed in the web root/META-INF folder, not in WEB-INF/classes/META-INF.

Boughton answered 27/10, 2014 at 11:1 Comment(4)
Thanks, do you have a link to back this up? Interestingly, persistence.xml should be deployed there according to this link: "If you package the persistence unit as a set of classes in a WAR file, persistence.xml should be located in the WAR file’s WEB-INF/classes/META-INF directory." If what you said is true, I guess this would imply a need for more than one META-INF location.Acme
Nothing interesting about it. persistence.xml is something entirely different and needs to be on the classpath (you can also use it in standard client applications). No I don't have a link to back it up since the official documentation doesn't explicitly state it. You can try it out yourself right now to confirm it.Boughton
OK, maybe "interesting" was the wrong word :-) But I'd assumed there would be only one META-INF folder in a web application - seems this was wrong.Acme
Ah, just found a similar question and someone who backs up what you said here - answer accepted.Acme

© 2022 - 2024 — McMap. All rights reserved.