glassfish
  1. glassfish
  2. GLASSFISH-6810

WebappClassLoader can not resolve resource with "." suffix

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 9.1peur2
    • Fix Version/s: 9.1.1_dev
    • Component/s: web_container
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      6,810
    • Status Whiteboard:
      Hide

      911Approved

      Show
      911Approved

      Description

      A web application using the approach described in 2.11.3 in
      https://jax-ws.dev.java.net/guide/Developing_client_application_with_locally_packaged_WSDL.html#Using__wsdlLocation_switch

      does not, the pojo web service client works with no issue, but it does not work
      if a servlet of jsp using the generated web service client class.

      Through debugging, the issue is (using the example code from the above link):

      baseUrl = client.MtomService.class.getResource(".");

      baseUrl returns null in this case.

      In a pojo case, the System class loader resolves the baseUrl correctly, but the
      classloader that loads the client.MtomService is WebappClassLoader, it can not
      resolve the resource with "." at the end, instead, if the statement is written as:

      baseUrl = client.MtomService.class.getResource("");

      The baseUrl is returned correctly.

      The implication is the web application as web service client can not work
      properly across environment.

      We have to modify the generated java code by replacing the "." to "", but it is
      a hack.

        Activity

        Hide
        mei_wu added a comment -

        Sorry for typos. To make it clearer, the described approach 2.11.3 in
        https://jax-ws.dev.java.net/guide/Developing_client_application_with_locally_packaged_WSDL.html#Using__wsdlLocation_switch

        is proven to work if the web service client is POJO but not if it is servlet or
        JSP. There is nothing wrong with the approach itself, but the problem is the
        WebappClassLoader can not resolve the url with "." at the end.

        Show
        mei_wu added a comment - Sorry for typos. To make it clearer, the described approach 2.11.3 in https://jax-ws.dev.java.net/guide/Developing_client_application_with_locally_packaged_WSDL.html#Using__wsdlLocation_switch is proven to work if the web service client is POJO but not if it is servlet or JSP. There is nothing wrong with the approach itself, but the problem is the WebappClassLoader can not resolve the url with "." at the end.
        Hide
        mei_wu added a comment -

        The version that I installed:
        glassfish-v2-ur2-b04-patch-20080915

        Show
        mei_wu added a comment - The version that I installed: glassfish-v2-ur2-b04-patch-20080915
        Hide
        harpreet added a comment -

        Please scrub issue for v2.1

        Show
        harpreet added a comment - Please scrub issue for v2.1
        Hide
        jluehe added a comment -

        I was able to verify the behaviour you are observing.

        However, when you say:

        WebappClassLoader can not resolve the url with "." at the end

        you don't really mean "url", but you are referring to the "path" argument passed
        to getResource(), right?

        In addition, you are not concerned with path names that have "." at the end,
        you are really concerned about path names that are equal to "." (i.e., contain
        just "."), right?

        The diffs below (created against the WebappClassLoader.java in 9.1 ur2) should
        fix the issue. I am going to attach a patch JAR file that has the diffs below
        incorporated. Can you please try it out and let me know? You would apply the
        patch by storing the JAR in your local file system, and then adding the absolute
        path to it to the classpath-prefix in your domain.xml. Let me know if you have
        any questions.

        Index: WebappClassLoader.java
        ===================================================================
        RCS file:
        /cvs/glassfish/appserv-webtier/src/java/org/apache/catalina/loader/WebappClassLoader.java,v
        retrieving revision 1.34.8.1
        diff -u -r1.34.8.1 WebappClassLoader.java
        — WebappClassLoader.java 14 Sep 2007 22:35:41 -0000 1.34.8.1
        +++ WebappClassLoader.java 19 Nov 2008 18:05:06 -0000
        @@ -1026,13 +1026,17 @@
        *

        • @param name Name of the resource to be found
          */
        • public URL findResource(final String name) {
          + public URL findResource(String name) {

        if (log.isTraceEnabled())
        log.trace(" findResource(" + name + ")");

        URL url = null;

        + if (".".equals(name))

        { + name = ""; + }

        +
        ResourceEntry entry = (ResourceEntry) resourceEntries.get(name);
        if (entry == null) {
        entry = findResourceInternal(name, name);

        Show
        jluehe added a comment - I was able to verify the behaviour you are observing. However, when you say: WebappClassLoader can not resolve the url with "." at the end you don't really mean "url", but you are referring to the "path" argument passed to getResource(), right? In addition, you are not concerned with path names that have "." at the end , you are really concerned about path names that are equal to "." (i.e., contain just "."), right? The diffs below (created against the WebappClassLoader.java in 9.1 ur2) should fix the issue. I am going to attach a patch JAR file that has the diffs below incorporated. Can you please try it out and let me know? You would apply the patch by storing the JAR in your local file system, and then adding the absolute path to it to the classpath-prefix in your domain.xml. Let me know if you have any questions. Index: WebappClassLoader.java =================================================================== RCS file: /cvs/glassfish/appserv-webtier/src/java/org/apache/catalina/loader/WebappClassLoader.java,v retrieving revision 1.34.8.1 diff -u -r1.34.8.1 WebappClassLoader.java — WebappClassLoader.java 14 Sep 2007 22:35:41 -0000 1.34.8.1 +++ WebappClassLoader.java 19 Nov 2008 18:05:06 -0000 @@ -1026,13 +1026,17 @@ * @param name Name of the resource to be found */ public URL findResource(final String name) { + public URL findResource(String name) { if (log.isTraceEnabled()) log.trace(" findResource(" + name + ")"); URL url = null; + if (".".equals(name)) { + name = ""; + } + ResourceEntry entry = (ResourceEntry) resourceEntries.get(name); if (entry == null) { entry = findResourceInternal(name, name);
        Hide
        jluehe added a comment -

        Created an attachment (id=2112)
        Patch JAR file

        Show
        jluehe added a comment - Created an attachment (id=2112) Patch JAR file
        Hide
        harpreet added a comment -

        Approving for v2.1

        Show
        harpreet added a comment - Approving for v2.1
        Hide
        jluehe added a comment -

        GlassFish v2.1 trunk:
        Checking in WebappClassLoader.java;
        /cvs/glassfish/appserv-webtier/src/java/org/apache/catalina/loader/WebappClassLoader.java,v
        <-- WebappClassLoader.java
        new revision: 1.34.6.11; previous revision: 1.34.6.10
        done

        SGES21_FCS_BRANCH:
        Checking in WebappClassLoader.java;
        /cvs/glassfish/appserv-webtier/src/java/org/apache/catalina/loader/WebappClassLoader.java,v
        <-- WebappClassLoader.java
        new revision: 1.34.6.10.2.1; previous revision: 1.34.6.10
        done

        GlassFish v3:
        Sending web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java
        Transmitting file data .
        Committed revision 23742.

        Unit test: appserv-tests/devtests/web/webappLoaderGetResourceDot

        Show
        jluehe added a comment - GlassFish v2.1 trunk: Checking in WebappClassLoader.java; /cvs/glassfish/appserv-webtier/src/java/org/apache/catalina/loader/WebappClassLoader.java,v <-- WebappClassLoader.java new revision: 1.34.6.11; previous revision: 1.34.6.10 done SGES21_FCS_BRANCH: Checking in WebappClassLoader.java; /cvs/glassfish/appserv-webtier/src/java/org/apache/catalina/loader/WebappClassLoader.java,v <-- WebappClassLoader.java new revision: 1.34.6.10.2.1; previous revision: 1.34.6.10 done GlassFish v3: Sending web/war-util/src/main/java/org/glassfish/web/loader/WebappClassLoader.java Transmitting file data . Committed revision 23742. Unit test: appserv-tests/devtests/web/webappLoaderGetResourceDot

          People

          • Assignee:
            jluehe
            Reporter:
            mei_wu
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: