1

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?

Spyros K
  • 2,480
  • 1
  • 20
  • 37
steelmonkey
  • 415
  • 2
  • 6
  • 19

2 Answers2

3

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.

steelmonkey
  • 415
  • 2
  • 6
  • 19
  • Besides using a separate `CATALINA_BASE`, Eclipse also published its applications to `wtpwebapps` (not subject to autodeploy) instead of `webapps`. – Piotr P. Karwasz Jan 27 '22 at 11:03
1

This configuration can be changed in the file $CATALINA_BASE/conf/server.xml.

Normally Eclipse uses the .metadata folder inside eclipse workspacespace for saving webapp data instead of the webapp folder of tomcat, but this can be changed also.

Eclipse controls the settings of its servers and uses other folders than the folder of tomcat so you have a more isolated development environment. See: Tomcat webapps directory in windows And How does Tomcat locate the webapps directory?

Community
  • 1
  • 1
Spyros K
  • 2,480
  • 1
  • 20
  • 37