Reputation: 3907
I have a Spring Boot application which I will deploy as a .war file in existing Tomcat and Undertow(Wildfly) containers. How can I configure the context path from within the application?
I know I can use the .war name directly, but I dont want to do that since the .war name contains version information etc.
Upvotes: 1
Views: 2993
Reputation: 10560
You can do this in the by adding a /WEB-INF/jboss-web.xml file in the application that you deploy:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.jboss.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<context-root>/</context-root>
</jboss-web>
As noted here: https://stackoverflow.com/a/28475123/912829
Upvotes: 1
Reputation: 6686
From Tomcat configuration docs Defining a context:
Individual Context elements may be explicitly defined:
- In an individual file at /META-INF/context.xml inside the application files. Optionally (based on the Host's copyXML attribute) this may be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to
application's base file name plus a ".xml" extension.- ...
Also note:
If you want to deploy a WAR file or a directory using a context path that is not related to the base file name then one of the following options must be used to prevent double-deployment:
- Disable autoDeploy and deployOnStartup and define all Contexts in server.xml
- Locate the WAR and/or directory outside of the Host's appBase and use a context.xml file with a docBase attribute to define it.
Also this is along the lines of what you are looking for How to set the context path of a web application in Tomcat 7.0
For undertow, if it's used as a web server in the wildfly AS try it with a jboss-web.xml like: https://stackoverflow.com/a/28475123/4807777
Upvotes: 3