[keycloak-user] Using dependencies for an SPI provider
Stian Thorgersen
sthorger at redhat.com
Fri May 27 02:53:07 EDT 2016
If you get a NoClassDefFoundError doing a search for "wildfly
module NoClassDefFoundError <CLASS>" usually gives you the details you
need. I've also got a script that searches through modules directory for a
jar with a specific class name, but only use that as a last resort. In case
you're on a Linux box I've attached it for you. You can run the script by
opening a shell in $KEYCLOAK_HOME/modules then run:
# searchjar org/jboss/logging/Logger
or
# searchjar org.jboss.logging.Logger
In this case I actually found the module needed easier with the searchjar
script, it's org.jboss.logging you want,
not org.jboss.logging.jboss-logging.
On 27 May 2016 at 08:38, Sarp Kaya <akaya at expedia.com> wrote:
> Hi Stian,
>
> Thanks for the response. How do you know that it belongs to sun.jdk
> module? I googled but I couldn’t find anything in regards to that.
>
> I managed to get through all the issues, the last stage is adding the log
> and now I am stuck again. I’m asking how you find the module name because
> now I am getting Caused by: java.lang.NoClassDefFoundError:
> org/jboss/logging/Logger error.
>
> I tried adding <module name="org.jboss.logging.jboss-logging”/> to the
> module.xml but that didn’t solve the problem.
>
> Kind Regards,
> Sarp Kaya
>
> From: Stian Thorgersen <sthorger at redhat.com>
> Reply-To: "stian at redhat.com" <stian at redhat.com>
> Date: Thursday, May 26, 2016 at 5:21 PM
> To: Abdullah Sarp Kaya <akaya at expedia.com>
> Cc: "keycloak-user at lists.jboss.org" <keycloak-user at lists.jboss.org>
> Subject: Re: [keycloak-user] Using dependencies for an SPI provider
>
> If you need additional dependencies in your provider please deploy it as a
> module, see docs and examples on how to do that. For the missing class
> you're module definition would need to include:
>
> ...
> <dependencies>
> <module name="sun.jdk" export="true" >
> <imports>
> <include path="sun/misc/Unsafe" />
> </imports>
> </module>
> </dependencies>
> ...
>
> On 26 May 2016 at 09:14, Sarp Kaya <akaya at expedia.com> wrote:
>
>> Hi,
>>
>> I am trying to extend an event listener and the example one works fine,
>> which just prints out every event.
>> However I want to do something more complicated than that. So I added two
>> more dependency on top of keycloak dependencies:
>> com.codahale.metrics:metrics-core and com.readytalk:metrics3-statsd
>>
>> In my IDE I was able to develop fine, then maven packages it fine. I
>> package it by including all the dependencies (so JAR file is like 6 MB),
>> otherwise it won’t have the dependencies (I have tried that and it
>> complained at the runtime saying it doesn’t have the class).
>>
>> Then I start the keycloak service, it starts fine. I get an exception
>> throw like below when I initially use the service (which is when the first
>> event trigger happens):
>>
>> 07:10:01,453 ERROR [io.undertow.request] (default task-6) UT005023:
>> Exception handling request to
>> /auth/realms/master/protocol/openid-connect/auth:
>> org.jboss.resteasy.spi.UnhandledException: java.lang.NoClassDefFoundError:
>> sun/misc/Unsafe
>> at
>> org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:76)
>> at
>> org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:212)
>> at
>> org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:168)
>> at
>> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:411)
>> at
>> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:202)
>> at
>> org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:221)
>> at
>> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
>> at
>> org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
>> at
>> io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
>> at
>> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
>> at
>> org.keycloak.services.filters.KeycloakSessionServletFilter.doFilter(KeycloakSessionServletFilter.java:88)
>> at
>> io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
>> at
>> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
>> at
>> io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
>> at
>> io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
>> at
>> io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
>> at
>> org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
>> at
>> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
>> at
>> io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
>> at
>> io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
>> at
>> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
>> at
>> io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
>> at
>> io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
>> at
>> io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
>> at
>> io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
>> at
>> io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
>> at
>> io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
>> at
>> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
>> at
>> org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
>> at
>> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
>> at
>> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
>> at
>> io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:284)
>> at
>> io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
>> at
>> io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
>> at
>> io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
>> at
>> io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
>> at
>> io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
>> at
>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>> at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>> at java.lang.Thread.run(Thread.java:745)
>> Caused by: java.lang.NoClassDefFoundError: sun/misc/Unsafe
>> at com.codahale.metrics.Striped64.getUnsafe(Striped64.java:330)
>> at com.codahale.metrics.Striped64.<clinit>(Striped64.java:311)
>> at com.codahale.metrics.EWMA.<init>(EWMA.java:29)
>> at com.codahale.metrics.EWMA.oneMinuteEWMA(EWMA.java:39)
>> at com.codahale.metrics.Meter.<init>(Meter.java:15)
>> at com.codahale.metrics.Meter.<init>(Meter.java:28)
>> at
>> com.codahale.metrics.MetricRegistry$MetricBuilder$3.newMetric(MetricRegistry.java:426)
>> at
>> com.codahale.metrics.MetricRegistry$MetricBuilder$3.newMetric(MetricRegistry.java:423)
>> at
>> com.codahale.metrics.MetricRegistry.getOrAdd(MetricRegistry.java:313)
>> at
>> com.codahale.metrics.MetricRegistry.meter(MetricRegistry.java:134)
>> at
>> com.expedia.keycloak.spi.providers.events.SysoutEventListenerProvider.<init>(SysoutEventListenerProvider.java:22)
>> at
>> com.expedia.keycloak.spi.providers.events.SysoutEventListenerProviderFactory.create(SysoutEventListenerProviderFactory.java:23)
>> at
>> com.expedia.keycloak.spi.providers.events.SysoutEventListenerProviderFactory.create(SysoutEventListenerProviderFactory.java:16)
>> at
>> org.keycloak.services.DefaultKeycloakSession.getProvider(DefaultKeycloakSession.java:115)
>> at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:498)
>> at
>> org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:56)
>> at com.sun.proxy.$Proxy81.getProvider(Unknown Source)
>> at org.keycloak.events.EventBuilder.<init>(EventBuilder.java:62)
>> at
>> org.keycloak.services.resources.RealmsResource.getProtocol(RealmsResource.java:98)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:498)
>> at
>> org.jboss.resteasy.core.ResourceLocatorInvoker.createResource(ResourceLocatorInvoker.java:79)
>> at
>> org.jboss.resteasy.core.ResourceLocatorInvoker.createResource(ResourceLocatorInvoker.java:58)
>> at
>> org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:100)
>> at
>> org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:395)
>> ... 37 more
>> Caused by: java.lang.ClassNotFoundException: sun.misc.Unsafe
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>> ... 66 more
>>
>> I don’t know what could be wrong. When I googled
>> the java.lang.NoClassDefFoundError with Keycloak I found that there was an
>> error with Facebook integration. So I am wondering whether this is
>> something similar and a bug with Keycloak? If not then what have I missed?
>>
>> Kind Regards,
>> Sarp Kaya
>>
>> _______________________________________________
>> keycloak-user mailing list
>> keycloak-user at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/keycloak-user
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/keycloak-user/attachments/20160527/0ba5e0c5/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: searchjar
Type: application/octet-stream
Size: 374 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/keycloak-user/attachments/20160527/0ba5e0c5/attachment-0001.obj
More information about the keycloak-user
mailing list