• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error 'element type listener not declared' when starting Tomcat

 
Laurence Met
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message above is generated when starting Tomcat (version 4.0.1).
I do not understand why, I thought that my DD was set up in the correct order.

Note that this code is based on Chap.5 Head First.

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">

<web-app>
<context-param>
<param-name>breed</param-name>
<param-value>Great Dane</param-value>
</context-param>

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

<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>
</web-app>
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're using pretty old stuff here Are you studying for SCWCD ? If so, you should use version 2.4, not 2.2.
http://faq.javaranch.com/view?ServletsWebXml

Did you try to remove the carriage return after com.example.MyServletContextListener ?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In fact, I'm looking at the 2.2 spec, and there's no listener tag.
Use 2.4 instead.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic