How can I tell e.g. Tomcat to use a specific context path when given my WAR-File?
Example:
I have a war file created by maven build and the resulting name of the file is rather long.
So I do not want the tomcat manager application to use the filename of the war as the context.
Supplying a context.xml in META-INF did not produce the desired results
I also found this in the documentation for the path
attribute of Context
:
The value of this field must not be set except when statically defining a Context in server.xml, as it will be inferred from the filenames used for either the .xml context file or the docBase.
So it does not seem to be the right way to tell the application-server what the path for my WAR should be.
Any more hints?
Best Answer
There are two important points in the the documentation of the Context Container:
So, when you bundle a
META-INF/context.xml
, the file gets renamed to the name of the WAR and this name becomes the context path, regardless of anypath
defined in theContext
element.I see thus two options here:
Either set the name of the generated war to a shorter name (I suggest using
<finalName>
over<warName>
which is deprecated AFAIK):Or use the
maven-tomcat-plugin
for the deployment and set the context path in the plugin configuration: