File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Tomcat 404 Error - Still not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat 404 Error - Still not working" Watch "Tomcat 404 Error - Still not working" New topic

Tomcat 404 Error - Still not working

miceal oconnor

Joined: Nov 07, 2001
Posts: 29
Hello Guys,
I've been following the discussions about the HelloWorld servlet not working in Tomcat v4.1.27. Since I suffer from the same problem I tried a few of the suggested solutions last night but to no avail.
I am running Redhat 9, Java SDK 1.4, J2EE1.2 & Tomcat 4.1.27 LE.
There were two main solutions to this problem:
1. Uncomment the following line in the web.xml file ( in conf dir ).
Stop / Start Tomcat.
This should have allowed me to view the URL http://localhost8080/myApp/HelloWorld
However I still got the 404 page not found error.
2. Next I looked at the examples which come with Tomcat & work.
They have the <servlet-mapping> & <url-pattern> tags in the applications web.xml file. So I edited my HelloWorld's web.xml & inserted these lines.
Stopped/started Tomcat but it still didn't work.
The only othre difference between the examples web.xml & my is a load of stuff about filters?
Can anybody help as I'm beginning to feel a lot of resentment towards Tomcat!!!
Cheers - Michael.
miceal oconnor

Joined: Nov 07, 2001
Posts: 29
Ooops .. I typed in the wrong URL.
it should have been http://localhost:8080/myApp/servlet/HelloWorld
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13035
The next thing to check is - do you have everything set so Tomcat will consider /myApp/ to be a web application with HelloWorld as a servlet?
Where is the myApp directory? Where is your HelloWorld class file?
Carl Trusiak

Joined: Jun 13, 2000
Posts: 3340
Following along the lines of Bill Questions. What package is HelloWorld in? If it's not in a package, maybe that's the cause. Give it a package say hello, rebuild it and put the class under WEB-INF/classes/hello
Now your URL should be http://localhost:8080/myApp/servlet/hello.HelloWorld

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
miceal oconnor

Joined: Nov 07, 2001
Posts: 29
Hello Guys,
Sorry for not getting back to you earlier!
In answer to Bills Question:
the directory path is /webapps/myApp/WEB-INF/classes
The web.xml file is in the WEB-INF directory.
The java files are in the classes directory.
In Answer to Karls question:
My Helloworld class is not a member of any package? Why does it need
to be? I'll have to check the examples directory in Tomcat but I don't believe they are a part of any package. However I will try your suggestion.
I just can't see why the examples work, but my code doesn't??
Thanks - Michael
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Servlets don't need to be in packages, though it's probably a good idea.
Beans and other classes referred to from JSPs do need to be in a package.

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
I agree. Here's the link:
subject: Tomcat 404 Error - Still not working
It's not a secret anymore!