File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

404 Error with Tomcat

 
Brad Strausbaugh
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying my first "Hello World" app with Tomcat which is much like the beer app in HFSJ. I'm using Tomcat 5.5 on XP. I've read the javaranch FAQ on Tomcat and I understand that Tomcat is not finding my target file, form.html.

I can launch Tomcat, then Firefox and bring up http://localhost:8080 just fine. But when I try http://localhost:8080/HelloWorldOne/form.html I get the 404 (unable to find /HelloWorldOne/form.html).

Modeling after the examples on HFJS p72-77, I have my form.html at ...

..\Tomcat 5.5\webapps\HelloWorldOne\form.html

Again, I'm following closely the deployment example on p73. I corrected a typo in my web.xml but I suspect that's an unrelated issue. Everything under WEB-INF is deployed as described in the HFSJ example.

Any advice is most welcome.

-Brad
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I take it your WEB-INF folder is in the HelloWorldOne folder?

Does the context show up in the manager app?

What happens if you simply address http://localhost:8080/HelloWorldOne/ ?
[ September 04, 2008: Message edited by: Bear Bibeault ]
 
Brad Strausbaugh
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying.

Yes, my WEB-INF is under HelloWorldOne ... like ...



- If I simply type http://localhost:8080/HelloWorldOne/ I also get a 404 error. I also tried putting a simple index.html under HelloWorldOne and got the same 404 error

- Interestingly, if I try http://localhost:8080/tomcat-docs (which is there thanks to the Tomcat install) I get that index.html just fine. It's strange.
[ September 04, 2008: Message edited by: Bear Bibeault ]
 
Brad Strausbaugh
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The directory hierarchy diagram didn't come through with the leading spaces, but yes, WEB-INF is under HelloWorldOne.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brad Strausbaugh:
The directory hierarchy diagram didn't come through with the leading spaces, but yes, WEB-INF is under HelloWorldOne.
Use UBB CODE tags to preserve formatting.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Does the context show up in the manager app?


And where's form.html?
 
Brad Strausbaugh
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
form.html is directly under HelloWorldOne and a peer of WEB-INF. I mistakenly left it out of my diagram but it is in fact in my directory. So correctly my directory looks like this ...



... and this is as things are when I enter http://localhost:8080/HelloWorldOne/form.html and the 404 error occurs.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13045
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this was my problem I would suspect that Tomcat is not seeing/parsing the web.xml file and thus does not recognize HellowWorldOne as a valid application thus form.html is "not available".

That is why Bear asked if the context shows up in the manager app.

Bill
 
Brad Strausbaugh
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the risk of sounding like a total moron, I don't know what that phrase "context shows in the manager app" means. What is the manager app? I see Tomcat running in a DOS shell and I can invoke it using a browser, and my app is HelloWorldOne. But what is the manager app?

-Brad
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The manager app shows you the contexts that are running in Tomcat and allows you to stop and start them individually. If the context is listed, the manager app will let you know if it's running or not. If it's not listed, the context isn't even being recognized.

I wrote an article on setting up Tomcat and the manager app for my jQuery in Action book. Visit the book's web site and download the example code. A PDF named tomcat.pdf will be found in the chapter8 folder. It will walk you through setting up a context and the manager application.
[ September 04, 2008: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so to make it easier, I put it online:
http://www.bibeault.org/jqueryinaction/tomcat.pdf
 
Brad Strausbaugh
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William and Bear, thanks for both of your replies.

Bear, your pdf was very eye-opening. I can run the Application Manager now and my /HelloWorldOne app appears on Applications, Running=false and Sessions=0. Is "Sessions" what you mean by "context" as in Session Context, or is there something else I'm missing? Sessions remains 0 when I try to invoke my HelloWorldOne app in another browser window, and of course I still get the 404 error.

Still no success but this is very interesting.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64173
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is "Sessions" what you mean by "context" as in Session Context,
No. "context" is the term for the web application itself. The running=false is the key. Your web app is not starting up for some reason even though it's recognized by Tomcat.

Anything in the logs?
[ September 05, 2008: Message edited by: Bear Bibeault ]
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there any errors in the log files 'TOMCAT_HOME/logs/*'??

Do you have a 'web.xml' file in the root of the WEB-INF folder??
 
Brad Strausbaugh
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear, William, Rene.

Got it! I had a typo in my web.xml </servlet-mapping> tag and I had totally left out my </web-app> tag.

Learning about the logs and the manager application is very good stuff.

I owe you guys a beer. I owe a lot of people beers.

-Brad
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic