*
The moose likes Servlets and the fly likes HTTP Status 404 servlet error ( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply locked New topic
Author

HTTP Status 404 servlet error ("The requested resource is not available")

Gar Morley
Greenhorn

Joined: Dec 15, 2004
Posts: 14
I'm having awful problems getting servlets up and running on Tomcat 5.5.4 (running under Linux Fedora Core). Every time I try to load a servlet I've written I get an error that says "HTTP Status 404 - /path/myServlet" (with a description further down saying "The requested resource (/path/myServlet) is not available").

The servlet itself is just a simple Hello World app without a package and in the ROOT directory of the Tomcat installation dir (I've tried putting it into a package and in the right directories under the install dir aswell). The web.xml file reads as follows:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

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

<servlet-mapping>
<servlet-name>Hello World</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>

(I didn't copy/paste this file so there might be typos above!)

HTML and JSP pages load fine if they are under the install_dir/ROOT/ folder but not if they are in a subfolderunder ROOT (!?) and all the Tomcat example servlets seem to work ok. I've tried putting servlets into the ROOT folder as well as under webapps/helloworld/WEB-INF/classes/HelloWorld.class with the web.xml file in the webapps/helloworld/WEB-INF folder.

Here's what I've tried so far based on info I found on the web:
-- I've enabled the invoker servlet in the main web.xml
-- I've enabled reloadable int the <Context> tag in the main context.xml
-- I've tried using the example servlets' web.xml file and added in my own details
-- I've set up my servlet as a .war in the webapps folder
-- I've gone through the tutorial at http://www.coreservlets.com/Apache-Tomcat-Tutorial/ and tired to set up Tomcat as described there (Everything works up until I put a HTML or JSP in a subfolder under ROOT or I try the first servlet test)

...but none of those have worked! =(

I'd be grateful if anyone could give me pointers on where to go from here to get a servlet working. Thanks for reading through all the detail!

~gar morley
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410


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

<servlet-mapping>
<servlet-name>Hello World</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>

webapps/helloworld/WEB-INF/classes/HelloWorld.class


If this is what you did (which looks right) then
http://localhos:8080/helloworld/HelloWorld
should work for you.


If you like, you can try some of my examples @
http://simple.souther.us
They're all war files so you only need to drop them in your webapps folder and they will run.

They all have proper mappings and directory structures.
[ February 27, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Brian Woo
Greenhorn

Joined: Feb 27, 2005
Posts: 4
I just got tomcat 5.5.7 setup and just did my testing servlet. The path to access the servlet is:

http://localhos:8080/servlet/HelloWorld
Gar Morley
Greenhorn

Joined: Dec 15, 2004
Posts: 14
Thanks for your reply.

Yeah, I'm running my apps by loading http://localhost/helloworld/HelloWorld (Tomcat is set up to use port 80 instead of 8080)

I've tried your SimpleServlet (thanks for the link) but that didn't work either. Does that suggest a Tomcat configuration problem to you? I'm going to post a plea on the Tomcat forum to see if anyone there has seen the problem, but if you think of anything servlet related I'd love to hear it here!

Thanks, ~gar
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

(Tomcat is set up to use port 80 instead of 8080)

There's your problem.
Look at TOMCAT_HOME/logs/catalina.out and you will probably see some "net bind exceptions".

Unix doesn't allow any processes to bind to ports < 1024 unless started by root.

Change the port back to 8080 until you have everything else running.
There are some options for getting to Tomcat to run on port 80 as a user other than root but get through the basics servlet stuff first.
Gar Morley
Greenhorn

Joined: Dec 15, 2004
Posts: 14
Port 80 seemed to be working fine (it brought up the test page etc (I couldnt find any net bind exceptions in catalina.out either)) but I changed it back to port 8080 anyway, but to no avail =( I'm still getting the same error whether I try to load one of my own servlets or one of your .war files.

I think I'l try to update Tomcat, or maybe try to set it up on a different machine.

Thanks for your help Ben and Brian, I'll post if I find a solution.
Gar Morley
Greenhorn

Joined: Dec 15, 2004
Posts: 14
I decided to give up on getting my tomcat 5.5.4 install to work so I downloaded 5.5.7. It _still_ didn't work when I installed it, but on restarting the computer I found that I had tomcat set to start up in my /etc/rc5.d/ directory. Once I removed the start and kill links in there it worked fine!
Iman
Greenhorn

Joined: Jul 12, 2006
Posts: 2
Hello...
I've got problem where "The requested resources is not avalaible"

Package : Report

Servlet : ReportOperation

My Mapping:
<servlet>

<servlet-name>ReportOperation</servlet-name>

<display-name>ReportOperation</display-name>

<servlet-class>ReportOperation</servlet-class>

</servlet>



<servlet-mapping>

<servlet-name>ReportOperation</servlet-name>

<url-pattern>/Report</url-pattern>

</servlet-mapping>



Structure web.xml :

C:\jakarta-tomcat-5.0.19\webapps\ROOT\WEB-INF\web.xml

Structure servlet:

C:\jakarta-tomcat-5.0.19\webapps\ROOT\WEB-INF\classes\Report\ReportOperation

Could anybody help....realy needs ur help...
TQ all.


sixnine
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

iman
Welcome to JavaRanch!

We're pleased to have you here with us in the Servlets forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here


Also, you've just brought up an old thread (raised a zombie).
Since most of the participants of this thread have probably moved on and since, in the case of this thread, the problem had to do with permissions on ports, it would be better if you started a new thread with your question.

Good-Luck
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HTTP Status 404 servlet error ("The requested resource is not available")
 
Similar Threads
Deploy a single servlet in Tomcat?
Servlet delivery in Tomcat
HTTP Status 404 problem
How to "Hello World"?
Having trouble getting Tomcat up and running