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.

1
  • I think WebContent/META-INF/context.xml is the right place Commented Oct 27, 2014 at 10:46

1 Answer 1

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.

4
  • 1
    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. Commented Oct 27, 2014 at 11:35
  • 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.
    – Gimby
    Commented Oct 27, 2014 at 11:37
  • 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. Commented Oct 27, 2014 at 11:41
  • 1
    Ah, just found a similar question and someone who backs up what you said here - answer accepted. Commented Oct 27, 2014 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.