• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't find my mistake trying HFSJ ServletContextListener demo

 
Patrick Beck
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranchers,

I'm trying ServletContextListener demo code starting on page 168 of HFSJ.
When running the URL http://localhost:8080/listenerTest/ListenTest.do in the webbrowser, the following error occured:


HTTP Status 404 - /listenerTest/ListenTest.do

type Status report

message /listenerTest/ListenTest.do

description The requested resource (/listenerTest/ListenTest.do) is not available.
Apache Tomcat/5.5.20


I checked several times web.xml and classes directory and couldn't find my mistake.

Here's my web.xml:

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<servlet>
<servlet-name>ListenerTester</servlet-name>
<servlet-class>com.example.ListenerTester</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>ListenerTester</servlet-name>
<url-pattern>/ListenTest.do</url-pattern>
</servlet-mapping>

<context-param>
<param-name>breed</param-name>
<param-value>Great dane</param-value>
</context-param>

<listener>
<listener-class>com.example.MyServletContextListener</listener-class>
</listener>


My directory structure in tomcat webapps:

ds@toshiba:~/prog/apache-tomcat-5.5.20/webapps/listenerTest$ l
total 4.0K
drwxr-xr-x 4 ds users 4.0K Nov 23 16:39 WEB-INF/
ds@toshiba:~/prog/apache-tomcat-5.5.20/webapps/listenerTest$ l WEB-INF/
total 16K
drwxr-xr-x 3 ds users 4.0K Nov 23 15:56 classes/
drwxr-xr-x 3 ds users 4.0K Nov 23 16:05 src/
-rw-r--r-- 1 ds users 640 Nov 23 16:31 web.xml
ds@toshiba:~/prog/apache-tomcat-5.5.20/webapps/listenerTest$l WEB-INF/classes/com/example/
total 12K
-rw-r--r-- 1 ds users 353 Nov 23 16:15 Dog.class
-rw-r--r-- 1 ds users 1.2K Nov 23 16:15 ListenerTester.class
-rw-r--r-- 1 ds users 837 Nov 23 16:21 MyServletContextListener.class
ds@toshiba:~/prog/apache-tomcat-5.5.20/webapps/listenerTest$ l WEB-INF/src/com/example/
total 12K
-rw-r--r-- 1 ds users 169 Nov 23 16:06 Dog.java
-rw-r--r-- 1 ds users 549 Nov 23 16:06 ListenerTester.java
-rw-r--r-- 1 ds users 437 Nov 23 16:21 MyServletContextListener.java


Any ideas whats going wrong?

Thanks for help.
Patrick

[ November 23, 2006: Message edited by: Patrick Beck ]
[ November 23, 2006: Message edited by: Patrick Beck ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check Tomcat's log files.
Also check that ListenerTester class is public.
 
Patrick Beck
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I forgot the ending </web-app> in web.xml *doh*
Thanks for help, I didnt realize that.
 
Srikanth Raghavan
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Patrick Beck:
I forgot the ending </web-app> in web.xml *doh*
Thanks for help, I didnt realize that.


Always indent your code, even when you don't use an IDE.

HTH,
Srikanth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic