Setting up a Tomcat Server under Eclipse

I recently decided to start using the tools at my disposal to their fullest, and so decided to start debugging my projects under Eclipse instead of just using Log4J statements to track stuff through the code. Why not?

And I had a Server set up under Eclipse, but its configuration has since bit-rotted, so it didn’t work. Which, as it turns out, is a good thing, since it forced me to relearn how to set up a Server (specifically a Tomcat 5.5 server) in Eclipse. The rest of this post is my crude attempt to document that endeavor. If there’s one thing I’ve learned about Eclipse, it’s that there are a hundred different ways to do just about anything. Probably including what I’m attempting to show here. What follows is what worked for me. I’m going to assume you are familiar with Eclipse and how to set things up in it. Also, I’m assuming that you have Tomcat 5.5 (or some similar version) installed already. What you had for breakfast, your college grade point average or favorite color are all up to you.

1. First, in the Java (default) perspective, open the Server/Servers View:

Open Server/Servers View

The Servers view will open somewhere in the IDE. Right click somewhere in the Servers view and choose New/Server and the New Server dialog will appear as if by magic.

New Server

2. Expand the Apache folder and several choices will be revealed to you. Choose the “Tomcat v5.5 Server” and the Server runtime you would like to use. If you don’t see the Server runtime you want (or none at all), then click on the Installed Runtimes… button and define one. If you already have a runtime set up, and selected it, skip to step 3. If you need to set up a Tomcat runtime, read on…

You will see a Preferences window that will allow you to add an installed Server Runtime (in the screen shot below, it shows one already set up… your mileage may vary).

Install New Server Runtime

Click the Add… button and you’ll see the New Server Runtime dialog, where you will select Apache Tomcat v5.5 and click Next > (not shown), at which point you will see the New Server Runtime dialog morph into the following:

New Server Runtime Details

In Tomcat installation directory you will type in (or use the Browse… button) the full path to your Tomcat installation. If you do not have Tomcat installed, please do so now. I’ll wait. Go on. No, seriously, I’ll wait.

Okay, good. Now that you’ve done that, select a JDK to use. I installed one in a different location because I just thought that would be cool, so I chose that one. You can try “Workbench Default” though that never worked well for me. And by not well, I mean, like, not at all. So, finish that up, clicking Ok, or Next where appropriate, and you will see a new inconfigured Server entry in your Servers View.

3. Open the New Server’s configuration by right-clickig on it and choosing “Open”. The configuration should open as a source file with a somewhat funky view. Click on the Open Launch Configuration link, which will open a dialog like the following:

Configure Server Launch

Select the Source tab and add your project. Next (and this is important), at the bottom of your new Server’s configuration View you’ll see two tabs. The one with which you’ve been interacting is the “Overview” tab. Click on the “Modules” tab, for you will have to now enter a web module that you would like to debug. Click the “Add External Web Module…” button and you will see this dialog:

New Web Module

Enter the appropriate “stuff” and you are nearly done. Tomcat has to be able to find your project, after all. If you try to debug and Tomcat starts REALLY quickly, you proably skipped this step (shame on you).

Now your server should be fully configured and ready to go. Have fun!

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: