0
votes

I do have a Spring Boot Application which uses custom context.xml for the tomcat. The context.xml contains property, defining the spring active profile

<Context>
    <Environment name="spring.profiles.active" value="profileName" type="java.lang.String" override="false" />
</Context>

File location is the /src/main/webapps/META-INF I was expecting that after the file is deployed to the tomcat, context xml will be automatically picked by tomcat and thrown to the conf/catalina/localhost/

As it turned out, the war was deployed, but the conf/catalina/localhost stayed empty.

After reading the docs i've found out that the server.xml has to be updated with the copyXML parameter as Host container. The documentation says:

copyXML Set to true if you want a context XML descriptor embedded inside the application (located at /META-INF/context.xml) to be copied to xmlBase when the application is deployed. On subsequent starts, the copied context XML descriptor will be used in preference to any context XML descriptor embedded inside the application even if the descriptor embedded inside the application is more recent. The flag's value defaults to false. Note if deployXML is false, this attribute will have no effect.

My Host looks like

<Host name="localhost"  appBase="webapps"
                  unpackWARs="true" autoDeploy="true" copyXML="true">
            </Host>

After restarting the server and redeploying the app, the /conf/Catalina/localhost still stayed empty.

Do you have any suggestions, what actions have to be taken in order to use custom context.xml?

1
The file should be in src/main/webapp/META-INF and I believe the name has to be context.xml (lowercase).M. Deinum
@M.Deinum sorry, it was a misstypeuser3049801

1 Answers

0
votes

I've figured it out. My build script did not copy the file correctly, the file name was not "context.xml" but "appName.xml" and tomcat didn't pick it up.