Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tomcat 404 Error - Still not working

 
miceal oconnor
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ).
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*<url-pattern>
<servlet-mapping>
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
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
Bill
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
miceal oconnor
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic