[keycloak-dev] Why isn't the configuration/providers directory on my classpath when attempting to load a file?

Josh Cain josh.cain at redhat.com
Tue Jan 12 09:51:43 EST 2016


Sounds good, thanks for pointing that out Stian and Marko.  Might work
through a little wrapping code now, but should be able to work with the lib
authors to get that changed.

Appreciate the help!

Josh Cain | Software Applications Engineer
*Identity and Access Management*
*Red Hat*
+1 843-737-1735

On Tue, Jan 12, 2016 at 3:55 AM, Marko Strukelj <mstrukel at redhat.com> wrote:

> What about simply wrapping the call in your provider that triggers
> third party loading the configuration with the TCCL wrapping code
> like:
>
> ClassLoader old = Thread.currentThread().getContextClassLoader();
> try {
>
> Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
>
>     callThirdPartyLibrary();
>
> } finally {
>     if (old != null) {
>         Thread.currentThread().getContextClassLoader(old);
>     }
> }
>
> If third party library only loads its files at init time, then one
> time call from within ProviderFactory init() should be enough, and
> other invocations should not require the TCCL wrapping code.
>
> On Tue, Jan 12, 2016 at 9:02 AM, Stian Thorgersen <sthorger at redhat.com>
> wrote:
> > The problem is in the library you're using as it shouldn't be using the
> > Thread.currentThread().getContextClassLoader(). It should use
> > getClass().getResource or getClass().getClassLoader(). Is there a way
> around
> > it?
> >
> > On 11 January 2016 at 23:24, Josh Cain <josh.cain at redhat.com> wrote:
> >>
> >> Hi all,
> >>
> >> I'm in the process of writing an SPI for a federation provider that
> relies
> >> on a third party library, and the library in turn uses a number of
> files.  I
> >> placed my SPI .jar, the third party library .jar, as well as its
> required
> >> files in the keycloak-1.7.0.Final/standalone/configuration/providers
> >> directory.  However, when the third party library attempts to locate its
> >> required files on the classpath, it cannot find them.
> >>
> >> Just for a sanity check, I've placed the files places like the
> >> sun/jdk/main module on the AS, and observed that the files were picked
> up
> >> properly since that particular folder was on the classpath.
> >>
> >> Can anyone help me understand why those files are not being picked up as
> >> classpath resources?  Does the configuration/providers directory not get
> >> added to the classpath?
> >>
> >> Just FYI, I poked through the library a bit, and it doesn't seem to be
> >> doing anything strange.  It winds up doing the equivalent of:
> >>
> >>
> >>
> Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
> >>
> >> Josh Cain | Software Applications Engineer
> >> Identity and Access Management
> >> Red Hat
> >> +1 843-737-1735
> >>
> >> _______________________________________________
> >> keycloak-dev mailing list
> >> keycloak-dev at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/keycloak-dev
> >
> >
> >
> > _______________________________________________
> > keycloak-dev mailing list
> > keycloak-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/keycloak-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-dev/attachments/20160112/d159edb7/attachment.html 


More information about the keycloak-dev mailing list