Resource loading is not properly delegated from DeploymentClassLoader
---------------------------------------------------------------------

                 Key: AXIS2-2738
                 URL: https://issues.apache.org/jira/browse/AXIS2-2738
             Project: Axis 2.0 (Axis2)
          Issue Type: Bug
          Components: kernel
    Affects Versions: 1.2
         Environment: Windows XP, Tomcat 5.5, Java 1.5.0_11
            Reporter: Fredrik Gustavsson


The getResourceAsStream method (in the DeploymentClassLoader class) fails to 
find resources available higher up in the classloader hierarchy.
For example when a service tries to load a resource available in a jar-file 
located in WEB-INF/lib (which means that it get loaded by the WebApp 
classloader in Tomcat which is an "grandparent" to the DeplymentClassLoader). 
In our case we have xmlbean genereated resources common to many services in 
that jar.

Reason:
DeploymentClassLoader .getResourceAsStream  calls 
DeploymentClassLoader.findResource which delegates to super.findResource 
(URLClassLoader).
URLClassLoader.findResource however doesn't delegate its search up the 
hierarchy.

A way to get it to work (at least for us) is to first call the getResource 
(ClassLoader) method in the DeploymentClassLoader .getResourceAsStream as the 
code below shows.



---- Modified DeploymentClassLoader .getResourceAsStream snippet

   public InputStream getResourceAsStream(String name) {
      URL url = getResource(name);

      if (url == null) {
         url = findResource(name);
      }
      if (url != null) {
         try {
            return url.openStream();
         }
         catch (IOException e) {
            throw new RuntimeException(e);
         }
      }

      return null;
   }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to