Issue
I'm merely curious, as to how Eclipse can make Tomcat run an EE webapp project from my own workspace folder instead of placing data within the webapps
folder of Tomcat.
My understanding is that for a webapp to run under Tomcat, its entire project structure must be placed inside of the webapps
folder directly underneath $CATALINA_HOME
, e.g. the folder that holds your Tomcat installation.
What makes this possible?
Solution
Eclipse runs a separate instance of Tomcat in a specially crafted environment. In this environment, the $CATALINA_BASE
variable has been set to a specific folder within your workspace's .metadata
folder.
In case you are not familiar, the $CATALINA_BASE
variable is set when you want to run a instance of Tomcat set up with entirely different environment arguments, variables and applications.
Normally, this variable is unset, but if Tomcat can detect that this variable is set, then it uses the configuration files in that specific folder's /conf
directory and behaves as if $CATALINA_BASE
is $CATALINA_HOME
.
The binaries in your $CATALINA_HOME/bin
folder are still used to invoke/manipulate instances, but everything else should be located and/or specified in the folder you're now pointing to, which should meet a proper Tomcat folder structure.
In my debian distro using Tomcat 8, the $CATALINA_BASE
is set to ~/Workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0
.
You should be able to see where $CATALINA_BASE
is set by examining the console logs of your Eclipse when Tomcat first starts up to output the results of a web application.
Answered By - steelmonkey
Answer Checked By - Katrina (JavaFixing Volunteer)