I'm building a JAVA (spring) app using Maven to do the install. My pom.xml file contains: <finalName>tools</finalName>
, so when I install it and upload the war file to tomcat, the domain is mydomain:8080/tools
. What do I need to change so it uses mydomain:8080/go/tools
instead?

- 8,872
- 9
- 55
- 65
-
`
go/tools ` – Nikolas Charalambidis Sep 29 '17 at 21:40 -
I tried that. It created the war file at: target/go/tools.war, but when I upload tools.war to the server, it's still at `:8080/tools` – Francis Lewis Sep 29 '17 at 21:42
-
Because there is kept also the previous one (`tools`), which you've to delete. have you tried to access `go/tools`? – Nikolas Charalambidis Sep 29 '17 at 21:43
-
define context path in `web.xml` or/and `context.xml` under tomcat/config. – Sergei Sirik Sep 29 '17 at 21:44
-
That was the issue I didn't understand. I couldn't just upload the war file, I had to set the context to /go/tools and tell the server where to pick up the war file instead of uploading it (using the apache tomcat admin gui). Now it's working. – Francis Lewis Sep 29 '17 at 21:47
1 Answers
You can do it like this:
If the Host deployXML flag is set to true, you can install a web application using a Context configuration ".xml" file and an optional ".war" file or web application directory. The Context Path is not used when installing a web application using a context ".xml" configuration file.
A Context configuration ".xml" file can contain valid XML for a web application Context just as if it were configured in your Tomcat server.xml configuration file. Here is an example for Tomcat running on Windows:
Use of the WAR or Directory URL is optional. When used to select a web application ".war" file or directory it overrides any docBase configured in the context configuration ".xml" file.
Here is an example of installing an application using a Context configuration ".xml" file for Tomcat running on Windows.
XML Configuration file URL: file:C:/path/to/context.xml Here is an example of installing an application using a Context configuration ".xml" file and a web application ".war" file located on the server (Tomcat running on Unix).
XML Configuration file URL: file:/path/to/context.xml WAR or Directory URL: jar:file:/path/to/bar.war!/
Or, you can simply change web app context path like this:
Add a file called
ROOT.xml
in<catalina_home>/conf/Catalina/localhost/
This ROOT.xml will override the default settings for the root context of the tomcat installation for that engine and host (Catalina and localhost).
Enter the following to the
ROOT.xml
file;
<Context docBase="<yourApp>" path="" reloadable="true" />
Just set path
to the path you want e.g. /go/tools
Also, as I mentioned above, you can do it pretty much the same way in either server.xml
or context.xml
under tomcat/config
folder.

- 1,249
- 1
- 13
- 28