0

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?

Francis Lewis
  • 8,872
  • 9
  • 55
  • 65

1 Answers1

1

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!/

Link

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

Link

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.

Sergei Sirik
  • 1,249
  • 1
  • 13
  • 28