Spring boot 2.0.1 application does not start with spring-cloud.version Finchley.RC1 but works fine with Finchley.M9 - maven

I am getting following exceptions while running a spring boot 2.0.1 application with spring clould version Finchley.RC1 but works fine if I change the version to Finchley.M9 in pom.xml as:
<spring-cloud.version>Finchley.RC1</spring-cloud.version>
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'propertySourceBootstrapConfiguration': Unsatisfied dependency expressed through field 'propertySourceLocators'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.company.configmanagement.springboot.autoconfig.CMBootstrapConfiguration$ConsulPropertySourceConfiguration': Unsatisfied dependency expressed through field 'configManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configManager' defined in com.company.configmanagement.springboot.autoconfig.ConfigManagementAutoConfiguration: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com.google.common.base.Splitter.splitToList(Ljava/lang/CharSequence;)Ljava/util/List; | AnnotationConfigApplicationContext:558
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'propertySourceBootstrapConfiguration': Unsatisfied dependency expressed through field 'propertySourceLocators'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.company.configmanagement.springboot.autoconfig.CMBootstrapConfiguration$ConsulPropertySourceConfiguration': Unsatisfied dependency expressed through field 'configManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configManager' defined in com.company.configmanagement.springboot.autoconfig.ConfigManagementAutoConfiguration: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: com.google.common.base.Splitter.splitToList(Ljava/lang/CharSequence;)Ljava/util/List;

Looks like it was a version compatibility issue as an internal dependency was pulling guava version 14.0. For now, using the following version of dependency fixed the issue.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>

Related

Getting the following error, any tips to resolving it? I am trying to convert from OAM to OKTA for authentication

I have a Spring application that I’ve been trying to switch over to Okta. I have not made it connect with OKTA yet. I am getting an error related to client registration.
I am using following dependencies
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<!-- <version>1.4.2.RELEASE</version>-->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<!--<version>1.5.2.RELEASE</version>-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
Application.properties
spring.security.oauth2.client.provider.okta.issuer-uri=https://dev-327711.okta.com/oauth2/default
spring.security.oauth2.client.registration.okta.provider=okta
spring.security.oauth2.client.registration.okta.client-name=awards2
spring.security.oauth2.client.registration.okta.client-id=xxxx
spring.security.oauth2.client.registration.okta.client-secret=xxxx
spring.security.oauth2.client.registration.okta.redirect-uri=/authorization-code/callback
spring.security.oauth2.client.registration.okta.scope=openid,profile,email
Error trace:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'securityConfiguration': Unsatisfied dependency expressed through method 'setContentNegotationStrategy' parameter 0;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration':
Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientWebMvcSecurityConfiguration':
Unsatisfied dependency expressed through method 'setClientRegistrationRepository' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientRegistrationRepository' defined in class path resource [org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]: Factory method 'clientRegistrationRepository' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.security.oauth2.client.registration.ClientRegistration.withRegistrationId(Ljava/lang/String;)Lorg/springframework/security/oauth2/client/registration/ClientRegistration$Builder;
After reading OAuth2 document I resolved this issue by adding "autoconfigure" dependency.
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.4.5</version>
</dependency>
https://docs.spring.io/spring-security-oauth2-boot/docs/2.0.0.RC2/reference/htmlsingle/

Flyway integration(Enterprise Version) in Spring Boot problem

Hello i got this error when i use flyway enterprise in my springboot project:
16:27:46 WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.scheduling.annotation.ProxyAsyncConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springAsyncConfig': Unsatisfied dependency expressed through field 'customAsyncExceptionHandler'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'customAsyncExceptionHandler': Unsatisfied dependency expressed through field 'importHistoryRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'importHistoryRepository': Cannot create inner bean '(inner bean)#31db34da' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#31db34da': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration': Unexpected exception during bean creation; nested exception is java.lang.TypeNotPresentException: Type org.flywaydb.core.api.callback.FlywayCallback not present
Here is my pom.xml file:
<dependency>
<groupId>org.flywaydb.enterprise</groupId>
<artifactId>flyway-core</artifactId>
<version>6.0.3</version>
</dependency>
Related to this Issue Flyway 6.x.x is not compatible with Spring Boot < 2.2.0.
So you got 2 Choices:
Update Spring Boot to >= 2.2.0
Use flyway 5.x.x
Hope this helps

how to resolve UnsatisfiedDependencyException with spring boot hibernate?

I am getting the following issue when Spring boot hibernates Connection.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookController': Unsatisfied dependency expressed through field 'bookService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookServiceImp': Unsatisfied dependency expressed through field 'bookDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookDaoImp': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getSessionFactory' defined in class path resource [com/go/myapp/Config/AppConfig.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
If you are building your project with maven look for the pom file. when you add dependencies there are Compile Dependencies for those dependencies. For an Example SpringBoot Starter 1.5.8.Release has https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter/1.5.8.RELEASE
SpringBoot 1.5.8.Release
SpringCore 4.3.12.Release
So please check your dependencies and there compile dependencies .
posting your POM file would help

(Spring 4.3.3-Hibernate 5.1.5)Unable to create sessionFactory object

Hi I am new to Hibernate and I am trying to integrate Spring 4.3.3 with Hibernate 5.1.5.
I am getting the following exception:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'loginController': Unsatisfied
dependency expressed through field 'loginservice'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'loginServiceImpl': Unsatisfied
dependency expressed through field 'loginDAO'; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'loginDAOImpl': Unsatisfied dependency
expressed through field 'hibernateTemplate'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'hibernateTemplate' defined in ServletContext
resource [/WEB-INF/db-config.xml]: Cannot resolve reference to bean
'sessionFactory' while setting constructor argument; nested exception
is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'sessionFactory' defined in ServletContext
resource [/WEB-INF/db-config.xml]: Invocation of init method failed;
nested exception is org.hibernate.MappingException: Could not get
constructor for
org.hibernate.persister.entity.SingleTableEntityPersister
My DB config file:
db-config.xml
Could someone please help me to solve this problem.

Spring annotation example server loading time it showing error

I am new in spring I am doing spring annotation example in eclipse luna same example working in myeclipse but not working in eclipse
getting this error can any one help me
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.vcs.service.StudentService com.vcs.controller.StudentController.studentService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.vcs.dao.StudentDao com.vcs.service.StudentServiceImpl.studentDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentdaoImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.vcs.dao.StudentdaoImpl.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/DispatcherServlet-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/context/CurrentSessionContext
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
Looking at the last error 'java.lang.NoClassDefFoundError' it looks as if you were missing a hibernate dependency (hibernate-core) that contains CurrentSessionContext.
You are getting a NoClassDefFoundError exception for org.hibernate.context.CurrentSessionContext.
My guess is that under your eclipse setup, the required dependencies are not inside your class path.
Check the lib folder inside you war archive for your eclipse build. I am assuming it's a WAR archive from the presence of WEB-INF.
Can I also suggest you format your code in a code block to make for easier reading

Resources