aspose file tools*
The moose likes Tomcat and the fly likes Tomcat 5.0.27  Http status 404 Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat 5.0.27  Http status 404 Error" Watch "Tomcat 5.0.27  Http status 404 Error" New topic
Author

Tomcat 5.0.27 Http status 404 Error

John Lincoln
Ranch Hand

Joined: Feb 11, 2003
Posts: 192
Hi,

I am trying to run an example servlet using 5.0.27 and having problems.


I have downloaded Tomcat 5.0.27 and did the initial configuration. The configuration was successfully and could see the tomcat page when i say http://localhost:8080.

Now i am trying to run my own HelloWorld example servlet.

Steps

1. I created a folder called FirstProject in webapps folder for my project.

The layout is as shown

webapps
|
|-->FirstProject
|
|-> helloworldexample.html
|-> WEB-INF(folder)
|->web.xml
|->classes(folder)
|->mypackage(folder)
|->HelloWorldExample.java
|->HelloWorldExample.class

My web.xml look as shown below

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<servlet>
<servlet-name>HelloWorldExample</servlet-name>
<servlet-class>mypackage.HelloWorldExample</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorldExample</servlet-name>
<url-pattern>/HelloWorldExample</url-pattern>
</servlet-mapping>
</web-app>

And the for the application, with new 5.0.27 tomcat version , each application should have its own context file in $CATALINA_HOME/conf/catalina/localhost/.

This is as per info in the url http://jakarta.apache.org/tomcat/tomcat-5.0-doc/config/context.html (Please note that for tomcat 5.x, unlike tomcat 4.x, it is NOT recommended to place <Context> elements directly in the server.xml file. Instead, put them in the META-INF/context.xml directory of your WAR file or the conf directory as described above)

I have created FirstProject.xml as my context file and placed in $CATALINA_HOME\conf\catalina\localhost\ and the contents are

<!--

Context configuration file for the Tomcat Administration Web App

$Id: admin.xml,v 1.3 2004/02/20 17:09:19 remm Exp $

-->


<Context path="/FirstProject" docBase="C:/Tomcat5.0/webapps/FirstProject/"
debug="0" privileged="true">

<!-- Uncomment this Valve to limit access to the Admin app to localhost
for obvious security reasons. Allow may be a comma-separated list of
hosts (or even regular expressions).
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127.0.0.1"/>
-->

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_admin_log." suffix=".txt"
timestamp="true"/>

</Context>


But when i run
http://localhost:8080/FirsProject/HelloWorldExample.
I get following error

HTTP Status 404 - /FirsProject/HelloWorldExample

--------------------------------------------------------------------------------

type Status report

message /FirsProject/HelloWorldExample

description The requested resource (/FirsProject/HelloWorldExample) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.27

Can someone please tell me what i am doing wrong. Please help.

thanks
Cheruvu
John Lincoln
Ranch Hand

Joined: Feb 11, 2003
Posts: 192
Hi,

Solved the problem. It was context in server.xml file Even though the version i am using 5.0.27, it does supports adding context path at the end of the file.

The problem was i used forward slash instead of backward slash ...my bad

thanks
Cheruvu
 
Consider Paul's rocket mass heater.
 
subject: Tomcat 5.0.27 Http status 404 Error