How to configure Apache Tomcat 7 in eclipse

MindsMapped
Building Apache Tomcat from source is very easy, and is the first step to contributing to Tomcat. The complete and comprehensive instructions are provided in the file BUILDING.txt. The following is a quick step by step guide.

1.Install Java.

Building Apache Tomcat requires a Java 6 JDK to be installed and optionally a Java 7 JDK installed in parallel with Java 6 one. The Java 7 JDK is only required if you wish to build Tomcat with JSR-356 (Java WebSocket 1.1) support. You can download JDKs from Oracle
http://www.oracle.com/technetwork/java/javase/downloads/index.html
or from another JDK vendor.IMPORTANT: Set an environment variable JAVA_HOME to the pathname of the directory into which you installed the Java 6 JDK. The path to Java 7 JDK is configured in build.properties file.

2. Unzip Tomcat.

Unzip tomcat-7.0.34-preconfigured.zip into the location of your choice. I use the top level of the C drive, which results in C:\apache-tomcat-7.0.34. I modified the port so Tomcat runs on 80 instead of 8080, and made two other small changes: enabling directory listings, and making the server automatically restart when faces-config.xml or struts-config.xml changes. These changes are useful during development, but only the port number change should be set for deployment servers. Alternatively, you can download any Tomcat 7 version from the Tomcat Web site and then copycontext.xmlserver.xml, and web.xml into install_dir/conf. These files are annotated with comments on what modifications were done to change the port to 80 and to enable directory listings and automatic server restarts

3.Install and start Eclipse.

Download from http://www.eclipse.org/downloads/. When you unzip Eclipse, the directory layout looks something like this:

eclipse/

features/                    ”the directory containing Eclipse features”

plugins/                      ”the directory containing Eclipse plugins”

eclipse.exe                  ”platform executable”

eclipse.ini

eclipsec.exe              ”(windows only) console executable”

epl-v10.html                ”the EPL license”

jre/                          ”the JRE to run Eclipse with”

notice.html

readme

You can start Eclipse by running eclipse.exe on Windows or eclipse on other platforms. This small launcher essentially finds and loads the JVM. On Windows, the eclipsec.exe console executable can be used for improved command line behavior.

4.Tell Eclipse about Tomcat.

Click on Servers tab at bottom. R-click, New, Server, Apache, Tomcat v7.0, navigate to Tomcat 7 installation folder (e.g., C:\apache-tomcat-7.0.34), OK. If you don’t see Servers tab, add the tab via Window, Show View, Servers.

5.Run Tomcat.

Click on Servers tab at bottom. R-click on Tomcat v7.0, choose “Start”. Open http://localhost/ in a browser (or http://localhost:8080/ if you downloaded Tomcat instead of using the preconfigured version, and then failed to change the port from 8080 to 80). Either way, you will see a 404 error message, but at least the message comes from Tomcat. Then, copy the ROOT app as described in the next section, come back, and reload http://localhost/ (or http://localhost:8080/ if using the unmodified version from the Tomcat download site). You should now see a friendly Tomcat welcome page. If you get a “port 80 is already in use” message, go to the Windows Control Panel, Services, and stop the other server (probably IIS). Also, on Linux and Solaris, you need admin privileges to start servers on low-numbered ports like 80. So, if you use the preconfigured Tomcat version but do not want port 80, double click on Tomcat at the bottom and change the port from 80 to something else (see “HTTP/1.1” in the “Ports” section on the right). But port 80 is nicer so that you can use URLs of the form http://localhost/app/blah instead of http://localhost:8080/app/blah, so using 80 should be your first choice.

6.Copy the ROOT (default) Web app into Eclipse.

Eclipse forgets to copy the default apps (ROOT, examples, docs, etc.) when it creates a Tomcat folder inside the Eclipse workspace. Go to C:\apache-tomcat-7.0.34\webapps and copy the ROOT folder. Then go to your Eclipse workspace, go to the .metadata folder, and search for “wtpwebapps”. You should find something like C:\your-eclipse-workspace-location\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps (or …/tmp1/wtpwebapps if you already had another server registered in Eclipse). Go to the wtpwebapps folder and paste ROOT (say “yes” if asked if you want to merge/replace folders/files). Then reload http://localhost/ to see the Tomcat welcome page.

Enter Your Comment

Your email address will not be published. Required fields are marked *