users@jersey.java.net

WADL generator resource loading uses the wrong class loader

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 10 Feb 2009 16:53:50 +0100

Hi Martin,

FYI see here:

   https://jersey.dev.java.net/issues/show_bug.cgi?id=207

Before we release 1.0.2 we have been testing Jersey installed onto GF
so that the Jersey jars do not need to be included in the war file.

The problem is i think the current resource loading technique of
com.sun.jersey.api.wadl.config.WadlGeneratorLoader is incorrect. It
assumes that:

   1) It can use the class loader of the wadl generator, which by
default belongs to Jersey and if part of GF will be loaded by
        a different class loader; and

   2) assumes that resource can be resolved to a File. Instead it
should be InputStream.

I think what we need to do what the MultiPart does for loading a
resource, which does:

         ClassLoader loader =
Thread.currentThread().getContextClassLoader();
         if (loader == null) {
             loader = this.getClass().getClassLoader();
         }

         // Attempt to find our properties resource
         InputStream stream = null;
         try {
             stream =
loader.getResourceAsStream(MULTI_PART_CONFIG_RESOURCE);
             if (stream == null) {
                 return;
             }

Paul.