[keycloak-user] How to create a Camel Route with Keycloak Admin Client in JBoss Fuse 6.3.0?

Celso Agra celso.agra at gmail.com
Thu Jun 15 23:44:42 EDT 2017


I'm considering to use another kind of osgi implementation, such as Apache
Karaf, eclipse virgo, etc... maybe some of these implementations are not
using CXF (I hope so!)
Also, I'll take a look in the effort to implement and call the Keycloak
REST endpoint with Apache CXF.

I'll create JIRA for this!

Thanks for your answer, Marek!

2017-06-15 5:15 GMT-03:00 Marek Posolda <mposolda at redhat.com>:

> Hi,
>
> I think that you're right. ATM our adminClient likely won't work inside
> JBoss Fuse as adminClient is a bit tightly coupled to resteasy JAXRS
> implementation and JBoss Fuse uses Apache CXF.
>
> At some point we had the PR and discussion for Apache CXF support of our
> admin client, but in the end, it wasn't done. Feel free to create JIRA for
> adminClient support in Fuse environment if it doesn't yet exists.
>
> The easiest workaround for you might be to call the REST endpoint manually
> (either with CXF or with Apache HTTP Client) and not use Keycloak builtin
> adminClient.
>
> Marek
>
>
> On 14/06/17 06:24, Celso Agra wrote:
>
>> Hi all,
>>
>> I'm trying to use the keycloak admin client in JBoss Fuse 6.3.0.
>> Everything
>> works fine when I run the java main class, but when I put this in the
>> JBoss
>> Fuse (with Karaf) I got an error, because the keycloak are using the
>> resteasy, and the OSGI is totally different. So, does anyone knows how to
>> do the same keycloak admin client configuration using this environment?
>>
>> Here is my log:
>>
>> javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request
>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Eng
>>> ine.invoke(ApacheHttpClient4Engine.java:289)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.
>>> invoke(ClientInvocation.java:454)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker
>>> .invoke(ClientInvoker.java:105)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.
>>> invoke(ClientProxy.java:76)
>>>
>>      at com.sun.proxy.$Proxy85.grantToken(Unknown Source)
>>
>>      at
>>
>>> org.keycloak.admin.client.token.TokenManager.grantToken(Toke
>>> nManager.java:89)
>>>
>>      at
>>
>>> org.keycloak.admin.client.token.TokenManager.getAccessToken(
>>> TokenManager.java:69)
>>>
>>      at
>>
>>> org.keycloak.admin.client.token.TokenManager.getAccessTokenS
>>> tring(TokenManager.java:64)
>>>
>>      at
>>
>>> org.keycloak.admin.client.resource.BearerAuthFilter.filter(
>>> BearerAuthFilter.java:52)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.
>>> invoke(ClientInvocation.java:431)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker
>>> .invoke(ClientInvoker.java:105)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.
>>> invoke(ClientProxy.java:76)
>>>
>>      at com.sun.proxy.$Proxy88.create(Unknown Source)
>>
>>      at
>>
>>> pe.gov.br.ati.service.KeycloakAdminManager.createUserKeycloa
>>> k(KeycloakAdminManager.java:64)
>>>
>>      at
>>
>>> pe.gov.br.ati.service.KeycloakClientService.validateAndInser
>>> tUser(KeycloakClientService.java:20)
>>>
>>      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>
>>      at
>>
>>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcce
>>> ssorImpl.java:62)
>>>
>>      at
>>
>>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMe
>>> thodAccessorImpl.java:43)
>>>
>>      at java.lang.reflect.Method.invoke(Method.java:498)
>>
>>      at
>>
>>> org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:408)
>>>
>>      at
>>
>>> org.apache.camel.component.bean.MethodInfo$1.doProceed(Metho
>>> dInfo.java:279)
>>>
>>      at
>>
>>> org.apache.camel.component.bean.MethodInfo$1.proceed(MethodI
>>> nfo.java:252)
>>>
>>      at
>>
>>> org.apache.camel.component.bean.BeanProcessor.process(BeanPr
>>> ocessor.java:177)
>>>
>>      at
>>
>>> org.apache.camel.management.InstrumentationProcessor.process
>>> (InstrumentationProcessor.java:77)
>>>
>>      at
>>
>>> org.apache.camel.processor.interceptor.TraceInterceptor.proc
>>> ess(TraceInterceptor.java:163)
>>>
>>      at
>>
>>> org.apache.camel.processor.RedeliveryErrorHandler.process(Re
>>> deliveryErrorHandler.java:468)
>>>
>>      at
>>
>>> org.apache.camel.processor.CamelInternalProcessor.process(Ca
>>> melInternalProcessor.java:196)
>>>
>>      at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
>>
>>      at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
>>
>>      at
>>
>>> org.apache.camel.processor.CamelInternalProcessor.process(Ca
>>> melInternalProcessor.java:196)
>>>
>>      at
>>
>>> org.apache.camel.component.direct.DirectProducer.process(Dir
>>> ectProducer.java:62)
>>>
>>      at
>>
>>> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
>>>
>>      at
>>
>>> org.apache.camel.management.InstrumentationProcessor.process
>>> (InstrumentationProcessor.java:77)
>>>
>>      at
>>
>>> org.apache.camel.processor.interceptor.TraceInterceptor.proc
>>> ess(TraceInterceptor.java:163)
>>>
>>      at
>>
>>> org.apache.camel.processor.RedeliveryErrorHandler.process(Re
>>> deliveryErrorHandler.java:468)
>>>
>>      at
>>
>>> org.apache.camel.processor.CamelInternalProcessor.process(Ca
>>> melInternalProcessor.java:196)
>>>
>>      at org.apache.camel.processor.Pipeline.process(Pipeline.java:121)
>>
>>      at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
>>
>>      at
>>
>>> org.apache.camel.processor.CamelInternalProcessor.process(Ca
>>> melInternalProcessor.java:196)
>>>
>>      at
>>
>>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProc
>>> essorHelper.java:109)
>>>
>>      at
>>
>>> org.apache.camel.processor.DelegateAsyncProcessor.process(De
>>> legateAsyncProcessor.java:91)
>>>
>>      at
>>
>>> org.apache.camel.component.restlet.RestletConsumer$1.handle(
>>> RestletConsumer.java:68)
>>>
>>      at
>>
>>> org.apache.camel.component.restlet.MethodBasedRouter.handle(
>>> MethodBasedRouter.java:54)
>>>
>>      at org.restlet.routing.Filter.doHandle(Filter.java:150)
>>
>>      at org.restlet.routing.Filter.handle(Filter.java:197)
>>
>>      at org.restlet.routing.Router.doHandle(Router.java:422)
>>
>>      at org.restlet.routing.Router.handle(Router.java:639)
>>
>>      at org.restlet.routing.Filter.doHandle(Filter.java:150)
>>
>>      at org.restlet.routing.Filter.handle(Filter.java:197)
>>
>>      at org.restlet.routing.Router.doHandle(Router.java:422)
>>
>>      at org.restlet.routing.Router.handle(Router.java:639)
>>
>>      at org.restlet.routing.Filter.doHandle(Filter.java:150)
>>
>>      at
>>
>>> org.restlet.engine.application.StatusFilter.doHandle(
>>> StatusFilter.java:140)
>>>
>>      at org.restlet.routing.Filter.handle(Filter.java:197)
>>
>>      at org.restlet.routing.Filter.doHandle(Filter.java:150)
>>
>>      at org.restlet.routing.Filter.handle(Filter.java:197)
>>
>>      at org.restlet.engine.CompositeHelper.handle(CompositeHelper.
>> java:202)
>>
>>      at org.restlet.Component.handle(Component.java:408)
>>
>>      at org.restlet.Server.handle(Server.java:507)
>>
>>      at
>>
>>> org.restlet.engine.connector.ServerHelper.handle(ServerHelper.java:63)
>>>
>>      at
>>
>>> org.restlet.engine.adapter.HttpServerHelper.handle(HttpServe
>>> rHelper.java:143)
>>>
>>      at
>>
>>> org.restlet.engine.connector.HttpServerHelper$1.handle(HttpS
>>> erverHelper.java:64)
>>>
>>      at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
>>
>>      at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
>>
>>      at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
>>
>>      at
>>
>>> sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Se
>>> rverImpl.java:675)
>>>
>>      at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
>>
>>      at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
>>
>>      at
>>
>>> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>>> Executor.java:1142)
>>>
>>      at
>>
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>>> lExecutor.java:617)
>>>
>>      at java.lang.Thread.run(Thread.java:748)
>>
>> Caused by: javax.ws.rs.ProcessingException: RESTEASY003215: could not
>> find
>>
>>> writer for content-type application/x-www-form-urlencoded type:
>>> javax.ws.rs.core.Form$1
>>>
>>      at
>>
>>> org.jboss.resteasy.core.interception.jaxrs.ClientWriterInter
>>> ceptorContext.throwWriterNotFoundException(C
>>> lientWriterInterceptorContext.java:40)
>>>
>>      at
>>
>>> org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInt
>>> erceptorContext.getWriter(AbstractWriterInterceptorContext.java:146)
>>>
>>      at
>>
>>> org.jboss.resteasy.core.interception.jaxrs.AbstractWriterInt
>>> erceptorContext.proceed(AbstractWriterInterceptorContext.java:121)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.wr
>>> iteRequestBody(ClientInvocation.java:388)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Eng
>>> ine.writeRequestBodyToOutputStream(ApacheHttpClient4Engine.java:589)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Eng
>>> ine.buildEntity(ApacheHttpClient4Engine.java:557)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Eng
>>> ine.loadHttpMethod(ApacheHttpClient4Engine.java:456)
>>>
>>      at
>>
>>> org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Eng
>>> ine.invoke(ApacheHttpClient4Engine.java:283)
>>>
>>      ... 70 more
>>
>>
>> Thanks for the attention.
>>
>>
>


-- 
---
*Celso Agra*


More information about the keycloak-user mailing list