14

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.

Steve Chambers
  • 37,270
  • 24
  • 156
  • 208

1 Answers1

16

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.

Gimby
  • 5,095
  • 2
  • 35
  • 47
  • 1
    Thanks, do you have a link to back this up? Interestingly, persistence.xml *should* be deployed there according to [this link](http://docs.oracle.com/cd/E19159-01/819-3669/bnbrj/index.html): "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. – Steve Chambers Oct 27 '14 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 Oct 27 '14 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. – Steve Chambers Oct 27 '14 at 11:41
  • 1
    Ah, just found a similar question and someone who backs up what you said [here](http://stackoverflow.com/questions/17997731/maven-war-has-meta-inf-folder-in-two-places#18017123) - answer accepted. – Steve Chambers Oct 27 '14 at 11:57