[jboss-as7-dev] cl.getResources() doesn't work from module-based code

Bill Burke bburke at redhat.com
Wed Sep 12 12:21:21 EDT 2012


Ok, in my LoginModule class, I outputed the results from using 
getClass().getClassLoader().getResources("META-INF/services" + ...);

This works fine.  But, this doesn't help me as internally Resteasy uses 
the thread context classloader to find services files.  How can I change 
resteasy so that it uses the correct classloader *internally* in all 
environments?  From a WAR deployment I need to find META-INF/services 
located both in the deployment and in any imported modules.

Read this did not help me:

https://community.jboss.org/wiki/ModuleCompatibleClassloadingGuide

Didn't help because I'm looking for resources spread out in different 
jars, so I don't have a classloader rrefernce point to use other than 
the context class loader.

On 9/12/2012 11:59 AM, Bill Burke wrote:
> Thing is, this works for regular Resteasy WAR deployments.
> Thread.currentThread().getContextClassloader().
>
> On 9/12/2012 11:51 AM, Rob Cernich wrote:
>> I don't believe the context classloader is what you want.  You may have better luck with something like getClass().getClassLoader().
>>
>> Best,
>> Rob
>>
>> ----- Original Message -----
>>>
>>>
>>> On 9/12/2012 11:23 AM, David M. Lloyd wrote:
>>>> On 09/12/2012 10:18 AM, Bill Burke wrote:
>>>>> I'm creating a custom login-module that is declared within
>>>>> standalone.xml.  This module references a new module that I have
>>>>> deployed (see below).  The login-module class uses Resteasy to
>>>>> make
>>>>> invocations.  The problem is that Resteasy is not able to find and
>>>>> register built-in providers.  Resteasy does this by doing:
>>>>>
>>>>>            Enumeration<URL> en =
>>>>> Thread.currentThread().getContextClassLoader().getResources("META-INF/services/"
>>>>> + Providers.class.getName());
>>>>>            while (en.hasMoreElements())
>>>>>            {
>>>>>               URL url = en.nextElement();
>>>>>
>>>>>
>>>>> No URLs are turning up when calling cl.getResources().  Is there
>>>>> some
>>>>> configuration switch I don't know about?
>>>>
>>>> Yeah - any time you have a dependency on a module whose
>>>> "META-INF/services" you want to access, you have to add
>>>> "services="import"" to that dependency, else that directory is
>>>> filtered out.
>>>
>>> <dependencies>
>>>            <module name="org.jboss.resteasy.resteasy-jackson-provider"
>>> services="import"/>
>>> </dependencies>
>>>
>>> Still doesn't work.
>>>
>>> Bill
>>>
>>> --
>>> Bill Burke
>>> JBoss, a division of Red Hat
>>> http://bill.burkecentral.com
>>> _______________________________________________
>>> jboss-as7-dev mailing list
>>> jboss-as7-dev at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
>>>
>

-- 
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com


More information about the jboss-as7-dev mailing list