Seems like spring boot 2.0.9.RELEASE and keycloak 6.0.1.final are the last
versions that are working.. If I go up to Spring boot 2.1.x I get this:
The bean 'httpSessionManager', defined in class path resource
[dk/tdc/netdesign/aspt/asptorion/security/SecurityConfig.class], could not
be registered. A bean with that name has already been defined in URL
[jar:file:/xxx.m2/repository/org/keycloak/keycloak-spring-security-adapter/6.0.1/keycloak-spring-security-adapter-6.0.1.jar!/org/keycloak/adapters/springsecurity/management/HttpSessionManager.class]
and overriding is disabled.
On Wed, Oct 2, 2019 at 2:21 PM nino martinez wael <
nino.martinez.wael(a)gmail.com> wrote:
Okay so right now I have reverted to spring boot 2.0.3.RELEASE and
keycloak 4.0.0.Final and it is working.. I'll try upgrading keycloak to 7
On Wed, Oct 2, 2019 at 10:25 AM nino martinez wael <
nino.martinez.wael(a)gmail.com> wrote:
> Hi Keycloakers,
>
> Im running on spring boot 2.1.8 and keycloak 7, and are getting
>
> 2019-10-02 10:17:58.523 INFO W7N15050 --- [ main]
> ConditionEvaluationReportLoggingListener :
>
> Error starting ApplicationContext. To display the conditions report
> re-run your application with 'debug' enabled.
> 2019-10-02 10:17:58.524 ERROR W7N15050 --- [ main]
> o.s.b.d.LoggingFailureAnalysisReporter :
>
> ***************************
> APPLICATION FAILED TO START
> ***************************
>
> Description:
>
> The bean 'httpSessionManager', defined in class path resource
> [dk/tdc/netdesign/aspt/asptorion/security/SecurityConfig.class], could not
> be registered. A bean with that name has already been defined in URL
>
[jar:file:/C:/Users/m24669/.m2/repository/org/keycloak/keycloak-spring-security-adapter/7.0.0/keycloak-spring-security-adapter-7.0.0.jar!/org/keycloak/adapters/springsecurity/management/HttpSessionManager.class]
> and overriding is disabled.
>
> Action:
>
> Consider renaming one of the beans or enabling overriding by setting
> spring.main.allow-bean-definition-overriding=true
>
> I am using
> @KeycloakConfiguration
> class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
> class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
> // Submits the KeycloakAuthenticationProvider to the
> AuthenticationManager
> @Autowired
> public void configureGlobal(AuthenticationManagerBuilder auth) throws
> Exception {
> KeycloakAuthenticationProvider keycloakAuthenticationProvider =
> keycloakAuthenticationProvider();
> keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new
> SimpleAuthorityMapper());
> auth.authenticationProvider(keycloakAuthenticationProvider);
> }
>
> @Bean
> public KeycloakSpringBootConfigResolver KeycloakConfigResolver() {
> return new KeycloakSpringBootConfigResolver();
> }
>
> // Specifies the session authentication strategy
> @Bean
> @Override
> protected SessionAuthenticationStrategy
> sessionAuthenticationStrategy() {
> return new RegisterSessionAuthenticationStrategy(new
> SessionRegistryImpl());
> }
>
>
> @Override
> protected void configure(HttpSecurity http) throws Exception {
> super.configure(http);
> http.authorizeRequests()
> .antMatchers("/**")
> .hasRole("user")
> .anyRequest()
> .permitAll();
> }
> }
> If I switch to KEYCLOAK-8725 solution
> I get this instead:
>
> 2019-10-02 10:23:00.888 WARN W7N15050 --- [ main]
> ConfigServletWebServerApplicationContext : Exception encountered during
> context initialization - cancelling refresh attempt:
> org.springframework.context.ApplicationContextException: Unable to start
> web server; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'tomcatServletWebServerFactory' defined in class path
> resource
>
[org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class]:
> Initialization of bean failed; nested exception is
> org.springframework.beans.factory.UnsatisfiedDependencyException: Error
> creating bean with name
> 'org.keycloak.adapters.springboot.KeycloakAutoConfiguration': Unsatisfied
> dependency expressed through method 'setKeycloakSpringBootProperties'
> parameter 1; nested exception is
> org.springframework.beans.factory.UnsatisfiedDependencyException: Error
> creating bean with name 'securityConfig': Unsatisfied dependency expressed
> through field 'keycloakConfigResolver'; nested exception is
> org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
> creating bean with name 'KeycloakConfigResolver': Requested bean is
> currently in creation: Is there an unresolvable circular reference?
> 2019-10-02 10:23:00.907 INFO W7N15050 --- [ main]
> ConditionEvaluationReportLoggingListener :
>
> Error starting ApplicationContext. To display the conditions report
> re-run your application with 'debug' enabled.
> 2019-10-02 10:23:00.913 ERROR W7N15050 --- [ main]
> o.s.b.SpringApplication : Application run failed
> org.springframework.context.ApplicationContextException: Unable to start
> web server; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error creating
> bean with name 'tomcatServletWebServerFactory' defined in class path
> resource
>
[org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class]:
> Initialization of bean failed; nested exception is
> org.springframework.beans.factory.UnsatisfiedDependencyException: Error
> creating bean with name
> 'org.keycloak.adapters.springboot.KeycloakAutoConfiguration': Unsatisfied
> dependency expressed through method 'setKeycloakSpringBootProperties'
> parameter 1; nested exception is
> org.springframework.beans.factory.UnsatisfiedDependencyException: Error
> creating bean with name 'securityConfig': Unsatisfied dependency expressed
> through field 'keycloakConfigResolver'; nested exception is
> 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.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156)
> at
>
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
> at
>
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
> at
> org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
> at
>
org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
> at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
> at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
> at
> org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)
> at
>
dk.tdc.netdesign.aspt.asptorion.AsptSpringApplication.main(AsptSpringApplication.java:33)
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'tomcatServletWebServerFactory' defined in class
> path resource
>
[org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration$EmbeddedTomcat.class]:
> Initialization of bean failed; nested exception is
> org.springframework.beans.factory.UnsatisfiedDependencyException: Error
> creating bean with name
> 'org.keycloak.adapters.springboot.KeycloakAutoConfiguration': Unsatisfied
> dependency expressed through method 'setKeycloakSpringBootProperties'
> parameter 1; nested exception is
> org.springframework.beans.factory.UnsatisfiedDependencyException: Error
> creating bean with name 'securityConfig': Unsatisfied dependency expressed
> through field 'keycloakConfigResolver'; nested exception is
> org.springframework.beans.factory.BeanCurrentlyInCreationException: Error
> creating bean with name 'KeycloakConfigResolver': Requested bean is
> currently in creation: Is there an unresolvable circular reference?
>
> --
> Best regards / Med venlig hilsen
> Nino Martinez
>
--
Best regards / Med venlig hilsen
Nino Martinez
--
Best regards / Med venlig hilsen
Nino Martinez