glassfish
  1. glassfish
  2. GLASSFISH-14593

WEB9052 Warnings when using Jersey during deployment

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: not determined
    • Component/s: web_container
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      14,593

      Description

      When a web app based around jersey is deployed, numerous warnings are generated,
      one for each resource method implemented of the following:

      WARNING: WEB9052: Unable to load class getError, reason:
      java.lang.ClassNotFoundException: getError

      where getError is actually a web resource method.

      The problem occurs because Jersey declares it interest in the javax.ws.rs.Path
      annotation which can be applied to both classes and methods. Unfortunately when
      building up the interest list in
      ServletContainerInitializerUtil::checkAgainstInterestList(lines 406-471) it
      assumes that all entries tagged as such are actually classes and tries to load
      them, which fails for methods with a ClassNotFoundException. A simple fix for
      this is would be to test if the annotatedElement (ae) is an instanceOf Type
      before attempting to load the class file. In addition, it may be a necessity to
      load the parent class if ae is an instance of a method or field.

        Activity

        Hide
        jsl123 added a comment -

        I'll leave the why to the web container guys, all I can say is that
        org.glassfish.web.loader.ServletContainerInitializerUtil builds a list of
        initializer interested annotations (interestList) using the handletypes value of
        all servlet context initializers. It then uses this list to get a list of all
        classes each servlet context initializer is interested in. It does this by using
        hk2 to return a list of all objects annotated with an annotation in the
        interestList. The problem is that this returns members as well as types, whereas
        the test assumes they are types and tries to load them.

        This is called by jersey as it delegates to the standard context - i think.

        Another (minor) issue is that the docs for ServletContainerInitializer say that
        the it should expect classes (it implies it is only ever looking for classes)
        not to be available and simply ignore them, optionally giving a log message if a
        config option is set if not. The current implementation logs a message regardless.

        Show
        jsl123 added a comment - I'll leave the why to the web container guys, all I can say is that org.glassfish.web.loader.ServletContainerInitializerUtil builds a list of initializer interested annotations (interestList) using the handletypes value of all servlet context initializers. It then uses this list to get a list of all classes each servlet context initializer is interested in. It does this by using hk2 to return a list of all objects annotated with an annotation in the interestList. The problem is that this returns members as well as types, whereas the test assumes they are types and tries to load them. This is called by jersey as it delegates to the standard context - i think. Another (minor) issue is that the docs for ServletContainerInitializer say that the it should expect classes (it implies it is only ever looking for classes) not to be available and simply ignore them, optionally giving a log message if a config option is set if not. The current implementation logs a message regardless.
        Hide
        jsl123 added a comment -
            • Issue 14593 has been confirmed by votes. ***
        Show
        jsl123 added a comment - Issue 14593 has been confirmed by votes. ***
        Hide
        Santiago Pericas-Geertsen added a comment -

        Fixed by verifying that AnnotatedElement is actually a Type before attempting to load it. If a
        Member or a Parameter, add its declaring type to result set.

        Sending web/war-
        util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java
        Transmitting file data .
        Committed revision 42938.

        Show
        Santiago Pericas-Geertsen added a comment - Fixed by verifying that AnnotatedElement is actually a Type before attempting to load it. If a Member or a Parameter, add its declaring type to result set. Sending web/war- util/src/main/java/org/glassfish/web/loader/ServletContainerInitializerUtil.java Transmitting file data . Committed revision 42938.
        Hide
        cowwoc added a comment -

        Santiago,

        What version is this fixed in?

        Show
        cowwoc added a comment - Santiago, What version is this fixed in?
        Hide
        rbento added a comment -

        I'm still getting this warning in GlassFish Server Open Source Edition 3.1.2 (build 23) by deploying a simple EAR with 2 web applications. One of the web applications uses Jersey.

        Show
        rbento added a comment - I'm still getting this warning in GlassFish Server Open Source Edition 3.1.2 (build 23) by deploying a simple EAR with 2 web applications. One of the web applications uses Jersey.

          People

          • Assignee:
            Santiago Pericas-Geertsen
            Reporter:
            jsl123
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: