glassfish
  1. glassfish
  2. GLASSFISH-18613

glassfish only instantiates the last of multiple <listener-class>es with a <listener>

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 3.1.2_b23
    • Fix Version/s: None
    • Component/s: deployment
    • Labels:
      None

      Description

      If multiple <listener-class> elements are nested within a <listener> tag, glassfish only instantiates the last of them, and doesn't log, warn, fail or otherwise indicate that it skipped over the previous ones.

      It seems to be allowed by web-app_2_5.xsd and tomcat instantiates each listener-class. If it turns out its really not allowed by the spec, the deployment should either fail or log a warning as appropriate.

      workaround: scope each <listener-class> within its own <listener> tag.

        Activity

        Hide
        Shing Wai Chan added a comment -

        According to schema, a <listener> must have one <listener-class> sub-element.

        Show
        Shing Wai Chan added a comment - According to schema, a <listener> must have one <listener-class> sub-element.
        Hide
        Shing Wai Chan added a comment -

        Suppose one has the following in web.xml

            <listener>     
                <listener-class>test.ServletTest1</listener-class>
                <listener-class>test.ServletTest</listener-class>
            </listener>
        

        If one put a xml schema info as follows:

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

        then the deployment fails as expected.

        But if one put only
        <web-app>

        Then the deployment successes.

        Show
        Shing Wai Chan added a comment - Suppose one has the following in web.xml <listener> <listener-class>test.ServletTest1</listener-class> <listener-class>test.ServletTest</listener-class> </listener> If one put a xml schema info as follows: <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd "> then the deployment fails as expected. But if one put only <web-app> Then the deployment successes.
        Hide
        Shing Wai Chan added a comment -

        The schema validation codes are in deployment.

        Show
        Shing Wai Chan added a comment - The schema validation codes are in deployment.
        Hide
        Hong Zhang added a comment -

        The deployment code invokes the underlying JAXP to do validation.

        I tried something similar to Shingwai (where the listener element defines more than one listener classes), the JAXP validation fails the deployment as expected.

        How does your listener element look like? Did you turn off the XML validation, otherwise the validation should've caught the error.

        Show
        Hong Zhang added a comment - The deployment code invokes the underlying JAXP to do validation. I tried something similar to Shingwai (where the listener element defines more than one listener classes), the JAXP validation fails the deployment as expected. How does your listener element look like? Did you turn off the XML validation, otherwise the validation should've caught the error.
        Hide
        Hong Zhang added a comment -

        We could not reproduce from our end and there was no additional information from user.

        Show
        Hong Zhang added a comment - We could not reproduce from our end and there was no additional information from user.

          People

          • Assignee:
            Hong Zhang
            Reporter:
            jonathaz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: