Hi,
I have an axis2 application (axis version 1.6.2 and Java7u51) that is 
internally using the ServiceLoader. The ServiceLoader needs to retrieve the 
implementation files as resouces from the META-INF/services folders inside any 
of the jars.
As the ServiceLoader is scanning the ContextClassLoader to retrieve this kind 
of resources I have set the context class loader to be of type "service". In 
this way it will contain all the jars of the aar package.
The classloader used is of type JarFileClassLoader and I think I have found a 
bug in the findResources(String name) method.
This method will load the resources from the parent classloader and from the 
classloader itself in an order that can be changed by configuration.

When the resources are retrieved from the parent classloader then it is just 
invoking:
parent.getResources(name);

When it tries to retrieve the resources from the urls of the classloader itself 
then it invokes:
super.findResources(name);
and this will invoke the findResources(String name) implementation in the 
java.net.URLClassLoader class. This method is not scanning directly the urls of 
the classloader, but it delegates to an object of type URLClassPath that is 
initialized in the constructor.
The problem is that in the JarFileClassLoader the constuctor methods do invoke 
the super contructor in the URLClassLoader that has to initialize the 
URLClassPath, but it does that using an emtpy url array and not the original 
array.

    public JarFileClassLoader(URL[] urls) {
        super(EMPTY_URLS);
        this.acc = AccessController.getContext();
        addURLs(urls);
    }

I also tried with different version of Java but because of this bug I am never 
able to successfully invoke getResources() or findResources() if I use a 
JarFileClassLoader.

Anybody has experieced the same? Is there a fix for this?

Thanks
Davide

Reply via email to