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

404 Error with Tomcat

Brad Strausbaugh
Greenhorn

Joined: Feb 25, 2007
Posts: 21
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

Joined: Jan 10, 2002
Posts: 61768
    
  67

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Brad Strausbaugh
Greenhorn

Joined: Feb 25, 2007
Posts: 21
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

Joined: Feb 25, 2007
Posts: 21
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

Joined: Jan 10, 2002
Posts: 61768
    
  67

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

Joined: Jan 10, 2002
Posts: 61768
    
  67

Originally posted by Bear Bibeault:
Does the context show up in the manager app?


And where's form.html?
Brad Strausbaugh
Greenhorn

Joined: Feb 25, 2007
Posts: 21
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

Joined: Mar 22, 2000
Posts: 12835
    
    5
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

Joined: Feb 25, 2007
Posts: 21
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

Joined: Jan 10, 2002
Posts: 61768
    
  67

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

Joined: Jan 10, 2002
Posts: 61768
    
  67

OK, so to make it easier, I put it online:
http://www.bibeault.org/jqueryinaction/tomcat.pdf
Brad Strausbaugh
Greenhorn

Joined: Feb 25, 2007
Posts: 21
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

Joined: Jan 10, 2002
Posts: 61768
    
  67

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

Joined: Oct 12, 2001
Posts: 1179

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??


Regards, Rene Larsen
Dropbox Invite
Brad Strausbaugh
Greenhorn

Joined: Feb 25, 2007
Posts: 21
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 404 Error with Tomcat