Search code examples
gradlewarmeta-inf

How to place context.xml in war's META-INF?


I am building a webapp through Gradle's war plugin. In order to disable Tomcat's session persistence, I need to place the file context.xml in the META-INF directory of the war's root.

I attempted the following:

  • Create the file src/main/webapp/META-INF/context.xml of the main project
  • Create the file src/main/resources/META-INF/context.xml of the main project

However, when I build the project using gradle clean war, the produced war file contains a META-INF with only a MANIFEST.MF in it. It is as if my directory gets overridden.

How do I place context.xml in the war?


Solution

  • src/main/webapp/META-INF/context.xml is correct and works fine for me. Chances are that you went wrong somewhere, or that there is a problem with your build script.