Announcement Announcement Module
Collapse
No announcement yet.
listener tag exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • listener tag exception

    I am running spring framework with Tomcat 4.1.31. In order to get the webApplicationContext to work, I have the following lines in my web.xml:

    <?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/dtd/web-app_2_3.dtd">
    <web-app>
    ......
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListe ner
    </listener-class>
    </listener>

    .....
    </web-app>

    but I got the following error message when Tomcat starts up:

    Nov 17, 2004 1:41:15 PM org.apache.commons.digester.Digester error
    SEVERE: Parse Error at line 78 column 13: Element type "listener" must be declar
    ed.
    org.xml.sax.SAXParseException: Element type "listener" must be declared.
    at org.apache.xerces.util.ErrorHandlerWrapper.createS AXParseException(Un
    known Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(U nknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.handleS tartElement(Unknown
    Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.startEl ement(Unknown Sourc
    e)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanStartElemen
    t(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl$FragmentContent
    Dispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(Un
    known Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(U nknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digeste r.java:1548)
    at org.apache.catalina.startup.ContextConfig.applicat ionConfig(ContextCo
    nfig.java:220)
    at org.apache.catalina.startup.ContextConfig.start(Co ntextConfig.java:57
    9)
    at org.apache.catalina.startup.ContextConfig.lifecycl eEvent(ContextConfi
    g.java:181)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(Lifecycl
    eSupport.java:119)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:3
    523)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase
    .java:774)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:76
    0)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:548)

    at org.apache.catalina.core.StandardHostDeployer.inst all(StandardHostDep
    loyer.java:260)
    at org.apache.catalina.core.StandardHost.install(Stan dardHost.java:741)
    at org.apache.catalina.startup.HostConfig.deployDirec tories(HostConfig.j
    ava:512)
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:354
    )
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:671)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java
    :311)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(Lifecycl
    eSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1149)

    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:707)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1141)

    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:316
    )
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:4
    50)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:214
    3)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:463)
    at org.apache.catalina.startup.Catalina.execute(Catal ina.java:350)
    at org.apache.catalina.startup.Catalina.process(Catal ina.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:156)
    Nov 17, 2004 1:41:15 PM org.apache.commons.digester.Digester error
    SEVERE: Parse Error at line 79 column 18: Element type "listener-class" must be
    declared.
    org.xml.sax.SAXParseException: Element type "listener-class" must be declared.
    at org.apache.xerces.util.ErrorHandlerWrapper.createS AXParseException(Un
    known Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(U nknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.handleS tartElement(Unknown
    Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.startEl ement(Unknown Sourc
    e)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanStartElemen
    t(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl$FragmentContent
    Dispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(Un
    known Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(U nknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digeste r.java:1548)
    at org.apache.catalina.startup.ContextConfig.applicat ionConfig(ContextCo
    nfig.java:220)
    at org.apache.catalina.startup.ContextConfig.start(Co ntextConfig.java:57
    9)
    at org.apache.catalina.startup.ContextConfig.lifecycl eEvent(ContextConfi
    g.java:181)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(Lifecycl
    eSupport.java:119)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:3
    523)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase
    .java:774)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:76
    0)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:548)

    at org.apache.catalina.core.StandardHostDeployer.inst all(StandardHostDep
    loyer.java:260)
    at org.apache.catalina.core.StandardHost.install(Stan dardHost.java:741)
    at org.apache.catalina.startup.HostConfig.deployDirec tories(HostConfig.j
    ava:512)
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:354
    )
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:671)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java
    :311)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(Lifecycl
    eSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1149)

    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:707)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1141)

    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:316
    )
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:4
    50)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:214
    3)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:463)
    at org.apache.catalina.startup.Catalina.execute(Catal ina.java:350)
    at org.apache.catalina.startup.Catalina.process(Catal ina.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:156)
    Nov 17, 2004 1:41:15 PM org.apache.commons.digester.Digester error
    SEVERE: Parse Error at line 107 column 11: The content of element type "web-app"
    must match "(icon?,display-name?,description?,distributable?,context-param*,ser
    vlet*,servlet-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-pa
    ge*,taglib*,resource-ref*,security-constraint*,login-config?,security-role*,env-
    entry*,ejb-ref*)".
    org.xml.sax.SAXParseException: The content of element type "web-app" must match
    "(icon?,display-name?,description?,distributable?,context-param*,servlet*,servle
    t-mapping*,session-config?,mime-mapping*,welcome-file-list?,error-page*,taglib*,
    resource-ref*,security-constraint*,login-config?,security-role*,env-entry*,ejb-r
    ef*)".
    at org.apache.xerces.util.ErrorHandlerWrapper.createS AXParseException(Un
    known Source)
    at org.apache.xerces.util.ErrorHandlerWrapper.error(U nknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.XMLErrorReporter.reportErro r(Unknown Source)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.handleE ndElement(Unknown S
    ource)
    at org.apache.xerces.impl.dtd.XMLDTDValidator.endElem ent(Unknown Source)

    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanEndElement(
    Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl$FragmentContent
    Dispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerI mpl.scanDocument(Un
    known Source)
    at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
    at org.apache.xerces.parsers.DTDConfiguration.parse(U nknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse( Unknown Source)
    at org.apache.commons.digester.Digester.parse(Digeste r.java:1548)
    at org.apache.catalina.startup.ContextConfig.applicat ionConfig(ContextCo
    nfig.java:220)
    at org.apache.catalina.startup.ContextConfig.start(Co ntextConfig.java:57
    9)
    at org.apache.catalina.startup.ContextConfig.lifecycl eEvent(ContextConfi
    g.java:181)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(Lifecycl
    eSupport.java:119)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:3
    523)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase
    .java:774)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:76
    0)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:548)

    at org.apache.catalina.core.StandardHostDeployer.inst all(StandardHostDep
    loyer.java:260)
    at org.apache.catalina.core.StandardHost.install(Stan dardHost.java:741)
    at org.apache.catalina.startup.HostConfig.deployDirec tories(HostConfig.j
    ava:512)
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:354
    )
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:671)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java
    :311)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(Lifecycl
    eSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1149)

    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:707)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1141)

    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:316
    )
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:4
    50)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:214
    3)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:463)
    at org.apache.catalina.startup.Catalina.execute(Catal ina.java:350)
    at org.apache.catalina.startup.Catalina.process(Catal ina.java:129)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:156)
    Nov 17, 2004 1:41:20 PM org.apache.struts.validator.ValidatorPlugIn initResource
    s
    INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml'
    Nov 17, 2004 1:41:23 PM org.apache.struts.validator.ValidatorPlugIn initResource
    s
    INFO: Loading validation rules file from '/WEB-INF/validator/validation.xml'
    Nov 17, 2004 1:41:23 PM org.apache.coyote.http11.Http11Protocol start
    INFO: Starting Coyote HTTP/1.1 on http-8888
    Nov 17, 2004 1:41:23 PM org.apache.jk.common.ChannelSocket init
    INFO: JK2: ajp13 listening on /0.0.0.0:8009
    Nov 17, 2004 1:41:23 PM org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/31 config=C:\tomcat-4.1.31\bin\..\conf\jk2.propert
    ies


    looks like the listener tag is not valid . But when I check the DTD file, listener tag is valid. The strange thing is that even with the exception, my actin class can still use WebApplicationContext to load a bean from applicationContext.xml file. Here is a code segment from my baseAction class:

    public void setServlet(ActionServlet actionServlet) {
    super.setServlet(actionServlet);
    ServletContext servletContext = actionServlet.getServletContext();
    WebApplicationContext wac = WebApplicationContextUtils
    .getRequiredWebApplicationContext(servletContext);
    this.nexus = (NexusFacade) wac.getBean("nexus");
    }


    Any suggestions, comments, solutions would be highly appreciated.

    Hanson Yuan

  • #2
    Your web.xml is specifying that you have a Servlet 2.2 webapp, so listeners are not yet supported for that version:

    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
    You need to specify:

    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    Erwin

    Comment


    • #3
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"

      Change the bold part to 2.3 and try again.
      Alef

      Comment


      • #4
        Thanks for the response. However, I still get the same error message. I though what important is the DTD file. But that DTD files does have listener tag in it.

        Comment

        Working...
        X