Is there a way to set the relative path to the docBase attribute in the context.xml of the web application, so it is outside the appBase directory of the tomcat server instance?
I would like to be able to exchange context configuration between computers and have an application living in a directory, not a war file. Thus, I can compile classes directly into this directory (in my project development directory) and use tomcat to use these classes without the need for copying / packaging.
I am using tomcat 8.0.0-RC5. My directory:
/home/david/projects/frontend/web-content <-- the static html files /home/david/projects/frontend/web-content/WEB-INF <-- the WEB-INF with the web.xml /home/david/projects/tomcat <-- tomcat base directory /home/david/projects/tomcat/Catalina/localhost <-- holds the frontend.xml context configuration
I tried
<?xml version="1.0" encoding="UTF-8"?> <Context path="/frontend" docBase="../../frontend/web-content"> </Context>
but it didnβt work. All the way to / web content seems to be ignored. The magazine says:
The main resource set specified [/home/david/projects/tomcat/webapps/web-content] is not valid
The Tomcat 8 documentation for the context container says:
You can specify the absolute path name for this directory or WAR file, or the path relative to the appBase directory of the Host owner.
Does the strict appBase subdirectory relative here (no .. allowed)?
Setting the absolute path works without problems. Configuration
<?xml version="1.0" encoding="UTF-8"?> <Context path="/frontend" docBase="/home/david/projects/frontend/web-content"> </Context>
It works, but it is specific to my computer. Therefore, I can no longer use the context configuration without changes.
I could create a symlink inside the appBase directory of the tomcat server and point it to the web content folder of my application. This would work, but I would have different configurations (symbolic links) on linux and windows machines.