Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tomcat configuration in Eclipse

I'm using Eclipse Luna with Tomcat 8 and am confused by the different locations of config files.

I've installed Tomcat on my local machine and configured Tomcat in Eclipse as follows:

enter image description here

So there are 4 directories involved

  • a) catalina home: C:\Program Files\AppServers\Tomcat8

  • b) catalina base: C:\Users\xxx\projectname\Tomcat

  • c) the configuration-path within my Eclipse workspace: /Servers/Tomcat v8.0 Server at localhost-config

  • d) Deploy path: wtpwebapps which is a subdirectory of a)

Both in a,b,c I have the same set of config-files (catalina.properties, context.xml, server.xml...). What is the hierarchy of these files, where do I configure my server for a specific application that I start from within Eclipse during development?

Edit: Related to this: What is happening if I right-click on the server in the servers-tab and choose "clean Tomcat working directory" or simply "clean"?

like image 764
Raphael Roth Avatar asked May 07 '15 07:05

Raphael Roth


People also ask

How do I open Tomcat in Eclipse?

Go to the project in the Project Explorer, select the web project, right click and select "Run As", you will see Apache Tomcat, create runtime configuration for the web project by selecting "New" button.

Does Eclipse have Tomcat?

Before configuring Tomcat in Eclipse, we'll have to install it first. The wizard will default the name of the server to localhost and the server name to Tomcat v9. 0 Server at localhost. Here, we'll specify the location of the Tomcat installation directory.

Where is Tomcat server xml in Eclipse?

In {workspace}/Servers you will find a folder for every Tomcat configuration, containing several configuration files, including the server. xml. There you then can edit the file directly.


2 Answers

Your configuration for the server that you start from Eclipse IDE are as you have given during the Server Location settings, in your case:

/Servers/Tomcat v8.0 Server at localhost-config

(This is configured in Eclipse, no need to modify them manually. But you can check the files if you want to make the same settings in "production" etc)


Now to the details...

About the hierarchy! As you already know, I hope, Catalina is the engine in tomcat which implements the Servlet/JSP parts.

C:\Program Files\AppServers\Tomcat8 here is your Tomcat8 binaries, where you have installed tomcat. It can run as stand-alone without Eclipse, but depends on the configuration you might not see the same apps as you deploy from Eclipse. This depends on your configuration in Eclipse.

C:\Users\xxx\projectname\Tomcat is your Tomcat custom folder, where you use in Eclipse. This you have chosen to make base and eclipse project separate. Maybe you dont want to touch the Tomcat8 installation. Here exists the needed files that Eclipse put to be able run a tomcat instance.

And with configuration in the subfolder /Servers/Tomcat v8.0 Server at localhost-config in above path.

When Eclipse run tomcat it uses the binaries (from C:\Program Files\AppServers\Tomcat8) with arguments for setting your base (i.e. C:\Users\xxx\projectname\Tomcat) and with the application folder (wtpwebapps) for deployments.

Read more at Eclipse Luna - Configuration of the Eclipse Workspace And you can always check the startup arguments to understand it better how everything is connected, see image below:

enter image description here

like image 162
MrSimpleMind Avatar answered Nov 16 '22 03:11

MrSimpleMind


Configuration files are stored in your workspace under a dedicated project (c).

Original path catalina home (a) is the path where Tomcat libraries are. Configuration is not being read from there... this allows a different configuration for the Tomcat when it is being run by Eclipse.

Catalina base (b) is a base path for work folders (temp and work) and also for deployed applications.

And the path for deployed applications (d) is just a name of the directory within catalina base where your applications are being deployed.


where do I configure my server for a specific application that I start from within Eclipse during development?

You don't configure it in any file, but rather within Eclipse. Your application needs to be configured as a Dynamic Web Project to enable server deployment.

like image 36
Pavel Horal Avatar answered Nov 16 '22 04:11

Pavel Horal