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?

5
  • <finalName>go/tools</finalName> Commented Sep 29, 2017 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 Commented Sep 29, 2017 at 21:42
  • Because there is kept also the previous one (tools), which you've to delete. have you tried to access go/tools? Commented Sep 29, 2017 at 21:43
  • define context path in web.xml or/and context.xml under tomcat/config. Commented Sep 29, 2017 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. Commented Sep 29, 2017 at 21:47

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.