[keycloak-user] Spring Boot Adapter: Error creating KeycloakConfigResolver with KC 4.5.0.Final

Pedro Igor Silva psilva at redhat.com
Fri Sep 28 13:51:41 EDT 2018


I found the cause of those errors that you are facing. To solve your
problem, do not return instances of KeycloakSpringBootConfigResolver. But
create your own implementation of KeycloakConfigResolver.

The KeycloakSpringBootConfigResolver changed to consider whether or not the
application is producing a bean for KeycloakConfigResolver to delegate
resolution of deployments to the bean. That was necessary to avoid
resolving deployments twice when using security constraints. See
KEYCLOAK-8133 for more details.

But yeah, backward compatibility is broken for spring security (spring
boot without spring security is fine though). Let's discuss on
https://issues.jboss.org/browse/KEYCLOAK-8444.

Thanks for the code.

On Fri, Sep 28, 2018 at 12:41 PM Niko Köbler <niko at n-k.de> wrote:

> Here's reproducable demo: https://github.com/dasniko/kc-sb-sec-demo
> Power it up and try to access http://localhost:9000/ - this will return a
> 500 and there's a loooong error on the console
> (You even don't need a KC server running, the error happens before
> accessing the server)
>
> - Niko
>
> Am 28.09.2018 um 17:23 schrieb Pedro Igor Silva <psilva at redhat.com>:
>
> OK, thanks for the update. I did test the solution I mentioned and it
> worked for one of the quickstarts we have.
>
> FYI, the changes you mentioned in KeycloakSpringBootConfigResolver are
> related to KEYCLOAK-8133. If you could give me something to reproduce the
> last issue you mentioned, I appreciate.
>
> Regards.
> Pedro Igor
>
> On Fri, Sep 28, 2018 at 12:16 PM Niko Köbler <niko at n-k.de> wrote:
>
>> Ok, there's a difference, but no working workaround...
>>
>> Previously, I declared the bean in a class annotated with
>> @KeycloakConfiguration - the described error occured when starting the
>> server up.
>>
>> After moving the bean definition to another class, annotated with
>> @Configuration only, the server powers up, but there are a lot (and I mean
>> really a lot) of these messages when I try to call the page in the browser:
>>
>> java.lang.StackOverflowError: null
>> at
>> org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver.resolve(KeycloakSpringBootConfigResolver.java:45)
>> ~[keycloak-spring-boot-adapter-core-4.5.0.Final.jar:4.5.0.Final]
>> at
>> org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver.resolve(KeycloakSpringBootConfigResolver.java:45)
>> ~[keycloak-spring-boot-adapter-core-4.5.0.Final.jar:4.5.0.Final]
>> at
>> org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver.resolve(KeycloakSpringBootConfigResolver.java:45)
>> ~[keycloak-spring-boot-adapter-core-4.5.0.Final.jar:4.5.0.Final]
>> .....
>>
>> I'll try to get a example app with the configuration over the weekend, so
>> that you are able to repdroduce. Unfortunately I now have to leave and
>> can't proceed to work on it.
>> In the meantime, if you like, you can have a look here:
>>
>> https://github.com/dasniko/keycloak-authdemo/blob/master/shop/src/main/java/dasniko/authdemo/shop/KeycloakAdapterSecurityConfig.java
>>
>> https://github.com/dasniko/keycloak-authdemo/blob/master/shop/src/main/java/dasniko/authdemo/shop/KeyclaokSpringSecurityConfig.java
>>
>> - Niko
>>
>>
>>
>> Am 28.09.2018 um 16:49 schrieb Pedro Igor Silva <psilva at redhat.com>:
>>
>> Can you confirm that you are able to workaround the issue by declaring
>> the bean creatin in a different class annotated with @Configuration ?
>>
>> Regards.
>>
>>
>> On Fri, Sep 28, 2018 at 11:21 AM Niko Köbler <niko at n-k.de> wrote:
>>
>>> Hi Sebi,
>>>
>>> thanks for confirming.
>>> Ticket is created: https://issues.jboss.org/browse/KEYCLOAK-8444
>>>
>>> - Niko
>>>
>>>
>>> Am 28.09.2018 um 16:09 schrieb Sebastien Blanc <sblanc at redhat.com>:
>>>
>>> Hi Niko !
>>>
>>> Indeed something is wrong here, I can reproduce it. Could you open a
>>> ticket ? I will take a look at it ASAP.
>>>
>>> Sebi
>>>
>>> On Fri, Sep 28, 2018 at 3:51 PM Niko Köbler <niko at n-k.de> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I just updated my Spring Boot w/ Spring Security demo installation to
>>>> KC 4.5.0.Final.
>>>> To be able to use the Spring Boot configuration with Spring Security
>>>> Adapter, I have this bean configuration:
>>>>
>>>> @Bean
>>>> public KeycloakConfigResolver keycloakConfigResolver() {
>>>>     return new KeycloakSpringBootConfigResolver();
>>>> }
>>>>
>>>> This worked well until 4.4.0.Final.
>>>> After upgrading to 4.5.0.Final, I get an error when Spring is trying to
>>>> create the bean registry. Here is the relevant part of the stack trace:
>>>>
>>>> Caused by:
>>>> org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
>>>> creating bean with name 'keycloakConfigResolver': Requested bean is
>>>> currently in creation: Is there an unresolvable circular reference?
>>>>         at
>>>> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:339)
>>>> ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
>>>>         at
>>>> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:215)
>>>> ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
>>>>         at
>>>> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
>>>> ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
>>>>         at
>>>> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
>>>> ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
>>>>         at
>>>> org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
>>>> ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
>>>>         at
>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1135)
>>>> ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
>>>>         at
>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1062)
>>>> ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
>>>>         at
>>>> org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:583)
>>>> ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
>>>>         ... 69 common frames omitted
>>>>
>>>>
>>>> I see, that there was a change in KeycloakSpringBootConfigResolver a
>>>> few days ago, but I don't really get it... Perhaps it's me, perhaps it's an
>>>> error?
>>>> Do I have to define my KeycloakConfigResolver bean in another way?
>>>>
>>>> Can anybody help me?
>>>>
>>>> Regards,
>>>> - Niko
>>>>
>>>>
>>>> _______________________________________________
>>>> keycloak-user mailing list
>>>> keycloak-user at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/keycloak-user
>>>
>>>
>>
>


More information about the keycloak-user mailing list