Google search bar

March 15, 2007

Running Tomcat from Eclipse (using the server view from WST)

From the eclipse server view (since WST is installed) you can create a new server.

  1. right-click in the view and selecting new > server
    1. Select the server you will be using (it was tomcat 5.5 in my case). You will want to have the server installed already.
    2. Choose a host name
    3. Choose a runtime. If there isn't one available, create one (press the available button)
  2. Press next
    1. Select any web projects you want to run on the new server. If there aren't any, you'll be creating one soon, I wager.
  3. Press finish and you are done.
Set up a new project, create a new "dynamic web project". That has some really nice stuff in it for managing the project. The jars in lib directory can automatically be part of the classpath. You can associate the project with a server that you've defined (or that you define after creating the project, if you wish).

Don't let eclipse overwrite the tomcat config (unless you want to)

From inside the server's editor (right-click the server in the view and select open) select the option to "Run modules directly from the workspace". Now any configuration that you have in the server's conf/ directory is safe from changes you make to the config of the server defined in eclipse.

In the same editor you can set up ports, MIME mappings and other important stuff.

Note: If you're going to have the server listen on port 80 rather than 8080, linux' root user is the only one that can bind that port. So, in linux you'll need to run eclipse as root. Or maybe you can come up with a better solution. Let me know if you do. This article describes other ways of running tomcat on port 80 with a user other than root. I have not tried these solutions, let me know how the work for you.

No comments: