[keycloak-user] Custom Authenticator and NoClassDefFoundError

Ryan Slominski ryans at jlab.org
Mon Jul 9 11:10:17 EDT 2018


Hi Keycloak Users,

I'm attempting to create a custom authenticator by following the org.keycloak.examples.authenticator secret question example and https://www.keycloak.org/docs/latest/server_development/index.html#_auth_spi documentation.  When I drop the jar file into the deployments directory I get a NoClassDefFoundError.  I guess this has something to do with the JBoss module system.  I tried added a jboss-deployment-structure.xml file with the "org.keycloak.keycloak-services" module, but now I get a ModuleNotFoundError.  Any tips?

Source code for new authenticator:

https://github.com/slominskir/KeycloakAutoLinkAuthenticator

NoClassDefFoundError:

2018-07-09 10:09:34,112 INFO  [org.jboss.as.repository] (DeploymentScanner-threads - 1) WFLYDR0001: Content added at location /opt/wildfly/keycloak-3.4.3/standalone/data/content/39/b99d3fa522078162e540b84481c8ff7c1fb346/content
2018-07-09 10:09:34,136 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "AutoLinkAuthenticator.jar" (runtime-name: "AutoLinkAuthenticator.jar")
2018-07-09 10:09:34,213 INFO  [org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor] (MSC service thread 1-2) Deploying Keycloak provider: AutoLinkAuthenticator.jar
2018-07-09 10:09:34,219 WARN  [org.jboss.modules] (MSC service thread 1-2) Failed to define class org.keycloak.extras.authentication.authenticators.broker.AutoLinkAuthenticator in Module "deployment.AutoLinkAuthenticator.jar" from Service Module Loader: java.lang.NoClassDefFoundError: Failed to link org/keycloak/extras/authentication/authenticators/broker/AutoLinkAuthenticator (Module "deployment.AutoLinkAuthenticator.jar" from Service Module Loader): org/keycloak/authentication/authenticators/broker/AbstractIdpAuthenticator
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
        at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
        at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:77)
        at org.jboss.modules.Module.loadModuleClass(Module.java:713)
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
        at org.keycloak.extras.authentication.authenticators.broker.AutoLinkAuthenticatorFactory.<clinit>(AutoLinkAuthenticatorFactory.java:14)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.lang.Class.newInstance(Class.java:442)
        at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
        at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
        at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
        at org.keycloak.provider.DefaultProviderLoader.load(DefaultProviderLoader.java:47)
        at org.keycloak.provider.ProviderManager.load(ProviderManager.java:93)
        at org.keycloak.services.DefaultKeycloakSessionFactory.loadFactories(DefaultKeycloakSessionFactory.java:213)
        at org.keycloak.services.DefaultKeycloakSessionFactory.deploy(DefaultKeycloakSessionFactory.java:114)
        at org.keycloak.provider.ProviderManagerRegistry.deploy(ProviderManagerRegistry.java:42)
        at org.keycloak.subsystem.server.extension.KeycloakProviderDeploymentProcessor.deploy(KeycloakProviderDeploymentProcessor.java:54)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)


ModuleNotFoundError:

2018-07-09 10:40:55,135 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.module.service."deployment.AutoLinkAuthenticator.jar".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.AutoLinkAuthenticator.jar".main: WFLYSRV0179: Failed to load module: deployment.AutoLinkAuthenticator.jar
        at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:91)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.modules.ModuleNotFoundException: keycloak-services
        at org.jboss.modules.Module.addPaths(Module.java:1217)
        at org.jboss.modules.Module.link(Module.java:1573)
        at org.jboss.modules.Module.relinkIfNecessary(Module.java:1601)
        at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:287)
        at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:271)
        at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:68)
        ... 5 more

Thanks,

Ryan


More information about the keycloak-user mailing list