Wednesday, February 16, 2011

Configure Tomcat Server in Eclipse WTP

Refer to the Download, Install.... post to download and install tomcat.. The rest.. just follow below....


refer the 4 steps(pasted below) of the link : http://www.vogella.de/articles/EclipseWTP/article.html

If tomcat does not start correctly.. then refere to the last section of this post...

1. Eclipse Web Tool Platform

Eclipse WTP provides tools for developing standard Java web applications and Java EE applications. Typical web artifacts in a Java environment are HTML pages, XML files, webservices, servlets and JSPs. Eclipse WTP simplifies the creation these web artifacts and provides runtime environments in which these artifacts can be deployed, started and debugged. In Eclipse WTP you create "Dynamic Web Projects". These projects provide the necessary functionality to run, debug and deploy Java web applications. If you are completely new to Java web development you may want to read Introduction to Java Webdevelopment .

Eclipse WTP supports all mayor webcontainer, e.g. Jetty and Apache Tomcat as well as the mayor Java EE application server. This tutorial uses Apache Tomcat as a webcontainer.

2. Tomcat Installation

Download the Apache Tomcat server 6.0.x from the following webpage http://tomcat.apache.org/. On MS Windows you can use the self-explanatory MS installer to install Tomcat. For a Tomcat installation on other platforms, please use Google.

After the installation test if Tomcat in correctly installed by opening a browser to http://localhost:8080/. This should open the Tomcat main page and if you see this page then Tomcat is correctly installed.

After verifying that Tomcat is correctly installed, stop Tomcat. Eclipse WTP is try to start Tomcat itself. If Tomcat is already running Eclipse WTP will not be able to use it for development.

3. Installation of

I assume you have downloaded the Eclipse IDE for Java developers . Use the Eclipse Update Manager to install all packages from the category "Web, XML, and Java EE Development" except "PHP Development".



4. WTP Configuration

Select Windows -> Preferences -> Server -> Runtime Environments to configure WTP to use Tomcat Press Add.

Select your version of Tomcat.

Tip

To compile the JSP into servlets you need to use the JDK. In my case the "Workbench default JRE" is pointing to the JDK. You can check you setup by clicking on "Installed JRE".

Press Finish and then Ok. You are now ready to use Tomcat with WTP.

4.1. Server

During development you will create your server. You can manager you server via the server view. To see if you data was persisted stop and restart the server. You can do this via the Windows -> Show View -> Servers -> Servers

The following shows where you can start, stop and restart your server.





Now,

Troubleshooting in case the Tomcat doesn't work...... or is throwing error for some missing jars.. then follow the link : http://mianniu.com/programming-world/java-lang-noclassdeffounderror-orgapachejulilogginglogfactory-at-org-apache-catalina-startup-bootstrap

Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
at org.apache.catalina.startup.Bootstrap.(Bootstrap.java:54)
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
… 1 more
Could not find the main class: org.apache.catalina.startup.Bootstrap. Program will exit.

Solutions

1. In Eclipse, Open the “Server” tab.
2. Double click on the “Tomcat6″ entry to see the configuration.
3. Then click on the “Open launch configuration” link in the “General information” block.
4. In the dialog, select the “Classpath” tab.
5. Click the “Add external jar” button.
6. Select the file “/usr/share/tomcat6/bin/tomcat-juli.jar”
7. Close the dialog.
8. Start tomcat 6 from Eclipse.


No comments:

Post a Comment