Search code examples
javajbosswildflyclassloaderkeycloak

Error with classloader in Keycloak and third party lib


I'm using Keycloak and some SPI what using different third party libraries. One of a libs containg some resource files inside of it. When I'm starting Keycloak, keycloak-server.war calling a SPI my-module.war.

Third party lib (in my-module.war) trying to find resource file by classloader with this line:

ClassLoader cl = Thread.currentThread().getContextClassLoader();

But when this line is executing I get "deployment.keycloak-server.war" classloader instead of "deployment.my-module.war" and module can't find own resource by this wrong classloader.

How can I avoid calling wrong classloader?


Solution

  • I found answer here: https://stackoverflow.com/a/36228195/12051567

    What was problem with context classloader.