Integrate Eclipse and Tomcat using JST Server Adapters

Installing JST
Go to marketplace, search for JST Server Adapters and install.

Configuring The Tomcat Runtime
Now that you've installed the JST, you can specify Tomcat as a Runtime Environment. Setting up a Runtime Environment in Eclipse basically means telling its engines where to look for your application server, so it can utilize its components and automatically configure your workspace.

To configure Tomcat as a new Runtime Environment, select the "Preferences" menu item from Eclipse's "Windows" menu (if you are using a Mac, you can find "Preferences" under the main Eclipse menu). You will be presented with large tree of preferences. Expand the "Server" preferences, and select "Runtime Environments". If this is the first time you have configured an application server in Eclipse, the list will be blank.

On the right hand side of the dialogue box, click the "add" button to call up the "New Server Runtime Environment" dialogue. You will be presented with a tree of application server vendors. Expand the Apache folder, and choose the version of Tomcat you have installed on your system. You will be asked to provide the path to Tomcat's base directory, as well as the path to the JRE you wish to use. As you will be compiling servlets, the JRE path should actually point to your JDK.

Creating A New Tomcat Server
To create a new Tomcat server in Eclipse, navigate to the "Server" tab, which is located in the lower half of Eclipse's development screen by default, and secondary click. Choose "New -> Server" from the context menu.

You will be presented with a dialogue in which you can configure high-level server setting such as default ports, server name, and host name. You can also use this dialogue to set your web application deploy path. If you would like more in depth information about setting up Tomcat servers in Eclipse, please visit Tomcat Eclipse, our illustrated step-by-step guide to using Tomcat with Eclipse.

Controlling your Existing Tomcat Installation with Eclipse
If you wish to integrate your existing Tomcat installation into Eclipse, rather than creating a new instance, follow the same steps as above for configuring a new server, and select "Use Tomcat installation" from the "Server Locations" tab of the Server Configuration menu.

Enabling Modern Context.XML Fragments
All actively supported versions of Tomcat allow web application Context Descriptors to be configured via context.xml fragments located in the application's "META-INF" directory. This allows users to make changes to applications and redeploy them without restarting the entire application server, as they would if the entries were included in "$CATALINA_HOME/conf/server.xml".

Eclipse supports this technique natively, but the option is enabled by default, in the interest of greater compatibility. If you wish to store application context information in a location other than "server.xml", check the "Publish module contexts to separate XML files" option in the "Server Options" tab of the Server Configuration menu.

Enabling JULI Logging
Apache Tomcat includes a version of the Java utility logger called JULI, which is modified for a container-based environment. Eclipse does not enable JULI by default when it creates new Tomcat servers.

In order to use JULI on your new Eclipse-configured server, copy "conf/logging.properties" from your root Tomcat installation folder into the "conf" folder of your new server. Next, in the Server Configuration menu, click the "Open launch configuration" link located in the "General Information" tab. In the "VM Arguments" field of the resulting Properties dialogue, add the JULI logging switches, as follows:

-Djava.util.logging.config.file="$CATALINA_BASE/conf/logging.properties"
-Djava.util.logging.manager=org.juli.ClassLoaderLogManager

Be the first to comment

Leave a Reply

Your email address will not be published.


*