I made a Spring-Boot application that I want to run in an external tomcat 8.
In a Spring-Boot application , the context-path can be chosen using the property server.context-path
in application.properties
but as I am using an external tomcat 8, this property is not used.
Hence, I took a look at the tomcat-8 documentation which states:
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.
As I do not want to pollute server.xml
, I chose the second option. Hence, I located the war in /home/myuser/myapp/application-1.0.0.war
and I placed a context file name application-1.0.0.xml
under conf/Catalina/localhost
. This file contains only those 2 lines :
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/myapp" docBase="/home/myuser/myapp"/>
I can see in the logs that tomcat8 starts successfully, the application appears to be deployed in the tomcat manager but :
- The path is
/application-1.0.0
instead of/myapp
. - Moreover, a directory
application-1.0.0
appears in thework
directory but stays empty. - The logs does not show any spring related logs as if the application had never been initialized.
Note : I know that the war is correct because it works if I place it in the webapp
directory (with the default context path though).
Note : If I rename application-1.0.0.xml
to foo.xml
, the tomcat manager shows that the application is deployed under context-path /foo
(but it is still never started).
Any ideas?