PhDeveloper
PhDeveloper

Reputation: 345

How to run an Eclipse Dynamic Web Application with Apache Tomcat Server?

I tried running Apache Tomcat Server on Eclipse and got into the following problems:

  1. The Catalina_Base is using a temporary location!
  2. I couldn’t deploy the dependencies "jar files"!
  3. I got the following exception when running my web project:
SEVERE: Servlet.service() for servlet [jsp] in context with path [] threw exception [java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;] with root cause java.lang.AbstractMethodError: javax.servlet.jsp.JspFactory.getJspApplicationContext(Ljavax/servlet/ServletContext;)Ljavax/servlet/jsp/JspApplicationContext;

Upvotes: 3

Views: 21539

Answers (1)

PhDeveloper
PhDeveloper

Reputation: 345

I managed to solve the above 3 problems by doing the following steps:

1- Double click your server (tomcat in this case) [if you can't see it go to Windows -> Show/View -> Other -> Server -> Servers]. Your server name will look something like: "Tomcat v7.0 Server at localhost".

Double click the server and make sure the Server Locations is set to : "Use Tomcat installation (takes control of Tomcat installation)". If you can't edit the servers location: Stop the server, right-click the server and select Publish. If still you cant edit it:

Right click the server --> Add and Remove and remove your project then publish it again.

The reason for selecting "Use Tomcat installation" is that Catalina_Base will point to a temporary location and will look something like:

"-Dcatalina.base="C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1"

This will cause a 404 Error even when trying to open Apache Tomcat Start Page. When selecting "Use Tomcat Installation" the Catalina_Home and Catalina_Base values will be the same and both will point to the Tomcat Installation Directory: Example:

-Dcatalina.base="C:\apache-tomcat-7.0.37" -Dcatalina.home="C:\apache-tomcat-7.0.37"

To see the Arguments:

Double Click the Server then click on "Open launch configuration", the values will appear in the "Arguments" tab.

2- When using dependencies (ex External Jar files), make sure the files are in : Web-Inf/lib and then add them to the class-path by doing the following:

Right-click the project --> Build-path --> Configure Build Path Select the "Libraries" tab Click Add External JARs and select the jar files in Web-Inf/lib

Next you need to deploy dependencies: To do this:

Right-Click the project -> Properties From the left side select "Deployment Assembly" On the right hand side click Add -> Java Build Path Entries -> Next Add all the jar files your project needs.

Otherwise, you'll get a class not found exception for the used jar files.

3- Make sure Web-Inf/lib does not contain any jar files from Apache Tomcat, as this will cause redundancies and will give the exception above!

Upvotes: 6

Related Questions