Spring Load .war context path for Undertow and Tomcat

I have a Spring Boot application that I will be using as a .war file in existing Tomcat and Undertow (Wildfly) containers. How do I set up the context path from within the application?

I know I can use the .war name directly, but I don't want to do that as the .war name contains version information etc.

+1


source to share


2 answers


From Tomcat Configuration Docs Defining Context:

Individual elements of the context can be explicitly defined:

  • In a separate file in the / META -INF / context.xml file inside the application files. Optional (based on the Host copyXML attribute), this can be copied to $ CATALINA_BASE / conf / [enginename] / [hostname] / and renamed to the
    name of the application base file plus the extension ".xml".
  • ...

Also note:



If you want to deploy a WAR file or directory using a context path that is not associated with the base file name, then one of the following parameters must be used to prevent duplicate deployment:

  • Disable autoDeploy and deployOnStartup and define all Contexts in server.xml
  • Find the WAR and / or directory outside the HostBase of the host and use the context.xml file with the docBase attribute to define it.

Also this matches what you are looking for How to set the context path for a web application in Tomcat 7.0

For a user, if it is used as a webserver in wildfly AS try it with jboss-web.xml like: fooobar.com/questions/707042 / ...

+3


source


You can do this by adding the / WEB -INF / jboss-web.xml file to the deployed application:

<?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: fooobar.com/questions/707042 / ...

+1


source







All Articles