[keycloak-dev] User apps and HttpClient

Marko Strukelj mstrukel at redhat.com
Fri May 22 09:15:58 EDT 2015


----- Original Message -----
> Hi,
> 
> On 22.5.2015 14:36, Marko Strukelj wrote:
> > @Vlastimil - a few questions:
> >
> > Do you use org.keycloak.adapters.HttpClientBuilder in your app?
> yes, colleague (in CC) who create the code used some example how to call
> Keycloak REST API from java code, so he uses this

Ok, in this case you have to make sure to include jboss-deployment-structure.xml that adds dependency on org.apache.httpcomponents. To make sure you use the right slot, open the modules/org/keycloak/keycloak-adapter-core/main/module.xml (could be in modules/system/layers/base). In that file find dependency on org.apache.httpcomponents and check if it has a slot="4.3".
In your jboss-deployment-structure.xml you have to use the same dependency. That's all. Things should then work. 

Or another option that Stian suggested ... don't use HttpClientBuilder at all. Forget about it. Use HttpClient directly. I think in that case it's up to you how you provide HttpClient to your .war. Haven't yet tried though. That one is on TODOs ...


> > Do you import any other class from org.keycloak.adapters in your app?
> no
> > Do you package httpclient.jar within your .war by any chance?
> no
> > Do you put jboss-deployment-structure.xml to your .war's /WEB-INF
> > Does your jboss-deployment-structure.xml look like this:
> >
> >      <jboss-deployment-structure>
> >            <deployment>
> >                <dependencies>
> >                    <module name="org.apache.httpcomponents" slot="4.3"/>
> >                </dependencies>
> >            </deployment>
> >      </jboss-deployment-structure>
> 
> Yes. I tried this both with and without slot="4.3" attribute but error
> is here in both cases.
> 

One of these cases should be a solution to your problem.

> A bit strange thing is that LinkageError has been thrown in finally
> block on call of
> client.getConnectionManager().shutdown();
> 
> When I commented this out then LinkageError arrised at line with
> HttpResponse response = client.execute(get);
> call, which is still not first occurence of httpclient in the method,
> but I understand that it is classloading problem which is always strange ;-)

Sounds like there is more going on here than what I initially described. There might be more ways of erroneous interaction between multiple versions of HttpClient than we currently see.
If you could make a reproducer and add it to JIRA that would be great ... as I'm a bit in the dark here now.

It could be related to this issue: https://issues.jboss.org/browse/KEYCLOAK-1338

- m


More information about the keycloak-dev mailing list