Setting up Eclipse and Tomcat Page
Setting up Eclipse and Tomcat
NOTE: Please do not download any softwares right now. All softwares are already copied into your desktop.
To create Servlet projects, you need to use a version of Eclipse with
J2EE support built in. The default version of Eclipse which you get
with Ubuntu does NOT include J2EE support, so you have to download a
version of Eclipse with J2EE support. You can get it from the Eclipse
download site:
http://www.eclipse.org/downloads/ (
choose according to your hardware configuration and OS)
Version: We are using Eclipse Juno
(4.2) Enterprise Edition in the workshop. We suggest you also use this
version, although an older version should also work fine if you are
already familiar with it and using it currently.
After downloading, extract the compressed archive on your local file
system. Then eclipse can be started by double-clicking on the eclipse
executable file.
Further, to run servlets, you need to use the tomcat server. Even the
Eclipse version with J2EE does not include the tomcat server, so you
have to download and set up tomcat. Details of how to do so are below.
Creating a Tomcat server and Linking from Eclipse
- Install Apache Tomcat (version 6 at least), either by
- using a package manager on your linux installation,
- Download from moodle
- or download Apache Tomcat from http://jakarta.apache.org/tomcat and extract the compressed file containing Apache Tomcat on your local file system.
- DO NOT use the system tomcat
installation which is usually on /usr/share/tomcat, since it is not
writable by you. If you do this you will run into trouble later.
- Add the Apache Tomcat runtimes to Eclipse. To do so, open Eclipse and do the following:
- Using the Preferences page, you can define the server runtime
environment definitions for the Apache Tomcat server. To define these
definitions, complete the following:
- From the Window menu, select Preferences.
- In the Preferences window, expand Server and then select Runtime Environments.
- On the Server Runtime Environments page, click Add. The New Server Runtime Environment wizard opens.
- On the New Server Runtime Environment page, expand Apache.
- Select one of the following supported Apache Tomcat servers:
- Apache Tomcat v6.0
- Apache Tomcat v7.0
- When you add a server runtime environment, by default a server is created and added as an entry in the Servers view. The Create a new local server check box is selected by default; do NOT change this setting.
- The Tomcat Server page opens when you click Next.
- In the Tomcat installation directory field, type or browse to the directory where you extracted the installation files of Apache Tomcat. For example, x:/apache-tomcat-6.0.13, where x is the installation directory of the Apache Tomcat server. Use a directory which is writable by you, NOT the /usr/share/tomcat directory.
- Click Finish.
- Configure and Test the Apache Tomcat server:
- Select Servers tab (look at the bottom right of the screen, along
with other tabs such as Markers and Properties). Now right-click and
select New > Server. The Define a New Server wizard opens.
- In the Select the server type list, select the Tomcat server defined in the previous step.
- Tip: If you did not specify the Tomcat install directory, the Define a New Server wizard will prompt you for this information.
- Start the Tomcat server. In the Servers view, right-click the Tomcat server and select Start.
- Test your setup of the Tomcat server.
- Open a Web browser.
- Type the Web addresshttp://localhost:8080/. If you see the Apache Tomcat start page, you have successfully set up your Tomcat server.
- If you see a 404 error message, but at least the
message comes from Tomcat. Reason for this issue is Eclipse forgets to
copy the default apps (ROOT, examples, etc.) when it creates a Tomcat
folder inside the Eclipse workspace. To resolve this follow bellow
steps.
- This is not mandatory
(Ref to bellow steps: http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html)
- Go to /webapps/ROOT, copy ROOT folder.
- Then go to your Eclipse workspace, go to the .metadata
folder(press ctrl + h to see this hidden folder) , and search for
"wtpwebapps". You should find something like your-eclipse-workspace/.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 it asks for merge/replace option).
- Then reload http://localhost:8080/ to see the Tomcat welcome page.
reference: iitb.ac.in/moodle
Comments