Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Trying to correctly configure tomcat, keep getting 'servlet not found error

843841Dec 20 2007 — edited Dec 21 2007
I keep getting this error:

'The requested resource (/servlet/HelloServlet) is not available'. (404)
The servlet is not getting located by tomcat for some reason. This happens when I go to localhost:8080/servlet/HelloServlet. (or localhost/HelloServlet)
The servlet engine is running, tomcat is running.

I did this:

javac -classpath /usr/local/tomcat/apache-tomcat-6.0.14/lib/servlet-api.jar HelloServlet.java

and I was able to at least compile the servlet into a .class file.

If you have tomcat installed, there should be an html document on how to configure it somewhere like here :
file:///usr/local/tomcat/apache-tomcat-6.0.14/webapps/docs/config/server.html
I've been studying this document trying to figure out what I need to do, but so far to no avail.

I added the folowing Context element to my context.xml, located in $CATALINA_HOME/conf:

<Context path="" docBase="webapps/ROOT" debug="0" reloadable="true"

crossContext="true">
</Context>


My HelloServlet.class is located in .../webapps/ROOT/WEB-INF/classes
In addition I added the following element to the bottom of my
..../webapps/ROOT/WEB-INF/web.xml to try to provide some sort of servlet mapping, I think:

<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>

I got this info mostly from doing Google research, so I dont know
how well this applies. The only thing I can think of at this point is maybe I need to set my
java -classpath also, but attempts to set it to my .../classes directory
fail. I'm not sure exactly what it needs to be set to, and if you have
to provide a .class filename every time. Could anybody help clarify
some of this ? I'm tired of just guessing from incomplete info and not getting anywhere. Thanx
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 18 2008
Added on Dec 20 2007
13 comments
1,446 views