NoClassDefFoundError: javax/servlet/http/HttpServlet

From one of the forum posting, i read that the classpath is missing servlet.jar.

I have a build.xml that points to the path of servlet-api.jar.

I am running the build before i start tomcat.

But when i try to run tomcat through eclipse (using sysdeo), I get the above error.

Can someone give pointers what am i doing wrong & how this can be fixed?

INFO: XML validation disabled

[DevLoader] Starting DevLoader

[DevLoader] JSPCompiler Classpath = /home/username/apache-tomcat-5.5.15/webapps/username/WEB-INF/classes/:

/home/username/apache-tomcat-5.5.15/bin/bootstrap.jar:

/usr/local/java/jdk1.5.0_06/jre/lib/ext/sunjce_provider.jar:

/usr/local/java/jdk1.5.0_06/jre/lib/ext/sunpkcs11.jar:

/usr/local/java/jdk1.5.0_06/jre/lib/ext/dnsns.jar:

/usr/local/java/jdk1.5.0_06/jre/lib/ext/localedata.jar:

java.lang.reflect.InvocationTargetException

Caused by: java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet

[1007 byte] By [javainsteada] at [2007-10-2 17:05:16]
# 1
You have to tell Eclipse where to find that servlet-api.jar, too. Put it in your Eclipse CLASSPATH along with your project's other 3rd party JARs. Right click on the project, select "properties", and follow along to where you add JARs.%
duffymoa at 2007-7-13 18:19:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Eclipse ignores system CLASSPATH. %
duffymoa at 2007-7-13 18:19:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Thanx for replying.

But that doesn't seem to help either. I already had servlet-api.jar in eclipse classpath.

It is pointing to the one uder $tomcat_home/common/lib

I have also set other jars in there "jasper-runtime.jar" & "jsp-api.jar"

anything else you could think of ?

javainsteada at 2007-7-13 18:19:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

I had this problem off and on, and I finally solved it by explicitly creating a <Context> element in a .xml file under $CATALINA_HOME/conf/<engine>/<host>/<appname.xml>.

appname.xml:

-

<Context path="/appname" docBase="appname" debug="0" reloadable="true" />

-

Now I don't have to rely on Tomcat/Catalina/whatever to automagically find my app.

The Apache configuration help gives details for other places you can put the element :

http://tomcat.apache.org/tomcat-5.5-doc/config/context.html

Hope this helps someone...

ScottEdgara at 2007-7-13 18:19:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
HttpServlet is also available in javaee.jar (as of 1.5). If you've installed the Java EE SDK, then add this jar to the build path of Eclipse.
BalusCa at 2007-7-13 18:19:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...