• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Tomcat 404 Error - Still not working

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ooops .. I typed in the wrong URL.
it should have been http://localhost:8080/myApp/servlet/HelloWorld
.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic