I have a maven application running on tomcat, I start it using cargo:
mvn cargo:run
Inside the webapps folder, there is a symlink that points to an important folder:
ls /usr/local/Cellar/tomcat/8.0.15/libexec/webapps/ROOT/WEB-INF/views
admin 898 Jul 21 2016 notImplemented.jsp
admin 3355 Oct 3 15:13 genericError.jsp
admin 41 Mar 21 18:43 vhosts -> /Users/me/Project/important/folder <<<<<< HERE
The problem is that when I start the server, tomcat follow the symlink and delete everything contained in the folder.
When I start tomcat via intellij, there is no issue. I noticed from the logs that the deletion is occurring at line 4 (Trying to delete WAR from /ROOT):
1 [INFO] [stalledLocalDeployer] Undeploying context [] from [/usr/local/Cellar/tomcat/8.0.15/libexec/webapps]...
2 [INFO] [stalledLocalDeployer] The WAR file has its context set to / and will therefore be deployed as ROOT.war
3 [INFO] [stalledLocalDeployer] Trying to delete WAR from [/usr/local/Cellar/tomcat/8.0.15/libexec/webapps/ROOT.war]...
4 [INFO] [stalledLocalDeployer] Trying to delete WAR from [/usr/local/Cellar/tomcat/8.0.15/libexec/webapps/ROOT]...
5 [INFO] [stalledLocalDeployer] Deploying [/Users/.....war] to [/usr/local/Cellar/tomcat/8.0.15/libexec/webapps]...
6 [INFO] [stalledLocalDeployer] The WAR file has its context set to / and will therefore be deployed as ROOT.war
I am running tomcat 8.0.15 on OSX 10.11.3 and use cargo-maven2-plugin v1.6.1.
Could you please suggest a solution to prevent symlinks content to be deleted when tomcat is starting ? Thanks
Solution
At the end, I am deleting all the symlinks contained inside tomcat working directory before starting tomcat. It fixes the problem.
find ${TOMCAT_HOME}/webapps -type l -delete