Spring boot version changes to 2.6.6 from 2.3.4.RELEASE - spring

I have changed the spring boot version to 2.6.6 from 2.3.4.RELEASE because of security vulnerabilities. My application's deployment is failing.
In pom.xml I have changed the version of only springboot.
<spring.boot.version>2.6.6</spring.boot.version>
Error Log:
Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '': Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '': Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '': Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '': Unsatisfied dependency expressed through field ''; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name '': Requested bean is currently in creation: Is there an unresolvable circular reference?"

Well the error message states
Requested bean is currently in creation: Is there an unresolvable circular reference?"
Usually spring boot displays the services for which the circularity was detected. I personally had this problem in the past. The dependency injection is not 100% deterministic and some unrelated changes in your project are now ending up in the detection of such an circular dependency. I am guessing that you are using
#Autowired
to inject you dependencies? When using constructor injection such problems are no longer exist Spring #Autowire on Properties vs Constructor
For now you sadly don´t have any other options then to resolve your circular dependency.
If i am wrong here you need to show more of your exception. from what little that we have it is hard to conclude what is going on :)

spring-boot family starting from 2.6.X not allowing circular reference
you can add to your properties this line:
spring.main.allow-circular-references=true

#GJohannes The code is tightly coupled and in many places, I am using #Autowired. Instead of this can I use spring.main.allow-circular-references=true

Related

Unable to create retry-able datasource for spring boot jdbc

I would like to add the retry feature for database connection certain number of times until the app acquires it. For the I have used the spring-retry on the DataSource but it is not working. It is throwing the following error
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jdbcTemplate' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/JdbcTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'jdbcTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: ExistingValue must be an instance of com.zaxxer.hikari.HikariDataSource
I have seen the debug logs but those are not helpful. Here is the sample source code . kindly help
Note: the dependencies mentioned in build.gradle is required for my app. I have only extracted the retry part.
Your use-case is delaying the start of Spring Boot until your database is up. Spring actually ships with a component that does that. The DatabaseStartupValidator is that component and has existed since about Spring 1.x.
You can add it as a bean and it will wait for further bootstrapping until the database is up.
#Bean
public DatabaseStartupValidator databaseStartupValidator(DataSource dataSource) {
var dsv = new DatabaseStartupValidator();
dsv.setDataSource(dataSource);
return dsv;
}
For a more detailed explanation see this blog post of mine.

Requested bean is currently in creation: Is there an unresolvable circular reference Jules cucumber test

Facing one issue related to integration of functional test in Jules Pipeline. When testing on local in IntelliJ, the functional cucumber test scripts are getting passed, but when deploying on jules , getting BeanCurrentlyInCreationException for all beans.
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authTokenInterceptor': Unsatisfied dependency expressed through field 'entitlementsFeignClient'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'mvcResourceUrlProvider': Requested bean is currently in creation
Is there an unresolvable circular reference?
Sometimes it passed and sometimes it fails with this exception.

Error with Springboot 2.4.0 incompatible versions

I have followed the below link and have updated the dependent jar versions respectively for spring boot 2.4.0.
But I get the following error while starting the service:
o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException.
Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0;
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'newRelicMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.class]: Unsatisfied dependency expressed through method 'newRelicMeterRegistry' parameter 2;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'newRelicClientProvider' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [io.micrometer.newrelic.NewRelicClientProvider]:
Factory method 'newRelicClientProvider' threw exception; nested exception is io.micrometer.core.instrument.config.validate.ValidationException: Multiple validation failures:
management.metrics.export.newrelic.apiKey was 'null' but it is required when publishing to Insights API
management.metrics.export.newrelic.accountId was 'null' but it is required when publishing to Insights API
So, I would like to understand where I will get compatible versions while upgrading to 2.4.0?
For example, I have updated these versions:
io.micrometer.micrometer-core // v1.6.2
io.micrometer.micrometer-registry-new-relic // v1.6.2
io.micrometer.micrometer-registry-prometheus // v1.6.2
spring.cloud.version // v2020.0.0-M6
org.springframework.cloud.spring-cloud-starter-sleuth // v2.2.5.RELEASE
redisson.version // v3.12.2
I am not familiar with the use of "io.micrometer.micrometer-registry-new-relic" api. But the problem looks like some validations are getting failed because of wrong value. Make sure your registry parameters are correct to get through the validations. Below is napshot of error from your error log.
nested exception is io.micrometer.core.instrument.config.validate.ValidationException: Multiple validation failures: management.metrics.export.newrelic.apiKey was 'null' but it is required when publishing to Insights API management.metrics.export.newrelic.accountId was 'null' but it is required when publishing to Insights API.
Also refer below link if that can help.
https://discuss.newrelic.com/t/error-with-micrometer-and-newrelic-with-springboot2/55988

Upgrade Spring 4.3.3 to Spring 5.0.1 Getting Errors

Can some one help me on this as I am getting this error and tried all the possible ways from my end and also tried checking with different options.
My application runs without error in Spring 4.3.3 where as when I upgrade to Spring 5.0.1 it gives the following error:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'controllerDependencyBean': Unsatisfied dependency expressed through field 'signUpService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'signUpServiceImpl': Unsatisfied dependency expressed through field 'notifyRepository'; nested exception is org.springframework.beans.factory.BeanCreationException.
All the versions and decencies are cross checked and all are correct and everything is fine, but still I get the above error. I am using Spring Security.

Spring Boot application WAR deployment to Resin 4: is there a way to use app (WEB-INF/lib) classloader first?

I'm trying to deploy Spring Boot app as a WAR to Caucho Resin 4. I'm getting an error on hitting the app:
org.springframework.context.ApplicationContextException: Unable to
start embedded container; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name
'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration'
: Bean instantiation via constructor failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration$
$EnhancerBySpringCGLIB$$58b91c9d]: Constructor threw exception; nested
exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'dashboardResource' defined in file
[/var/resin/webapps/itasng-0.8.5/WEB-INF/classes/gov/nih/cit/itasng/
rest/DashboardResource.class]: Unsatisfied dependency expressed through
constructor parameter 0; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'payPeriodRepository' defined in file
[/var/resin/webapps/itasng-0.8.5/WEB-INF/classes/gov/nih/cit/itasng/
persistence/PayPeriodRepository.class]: Unsatisfied dependency
expressed through constructor parameter 0; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name
'org.springframework.orm.jpa.SharedEntityManagerCreator#0': Cannot
resolve reference to bean 'entityManagerFactory' while setting
constructor argument; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'entityManagerFactory' defined in class path resource
[org/springframework/boot/autoconfigure/orm/jpa/
HibernateJpaAutoConfiguration.class]: Invocation of init method failed;
nested exception is java.lang.NoSuchMethodError:
javax.persistence.Table.indexes()[Ljavax/persistence/Index; at
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext
.onRefresh(EmbeddedWebApplicationContext.java:137)
~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
...
It's obvious that this is a typical class-loading issue: classes loaded by the parent class-loader from Resin lib (e.g. lib/javaee-16.jar) cause issues for the app built with newer versions (e.g. WEB-INF/lib/hibernate-jpa-2.1-api-1.0.0.Final.jar).
Most app servers that I used before have a setting somewhere in a vendor specific –web.xml descriptor to switch the classloader order so that WEB-INF/lib classes load first. However, the Resin docs don't really have an easy answer if such an option exists.
Is there a way to switch class loading order in Resin 4 or what would be an alternative solution?
In Resin 4.0 there is no way to use app classloader first.
Potential workarounds for related classloading issues could involve using
the <jvm-classpath> which has precedence over Resin's classpath.
An example use case is to use later versions of JPA instead of JPA 2.0, which is deployed out-of-the-box.
Documentation reference:
http://www.caucho.com/resin-4.0/admin/cluster-config.xtp#jvm-classpath

Resources