spring-data-elasticsearch 3.0.1.RELEASE got UnsatisfiedDependencyException - elasticsearch

I'm using spring-data-elasticsearch 3.0.1.RELEASE in springmvc with spring verison 4.1.1 .And my elasticsearch server is up 5.5.0
After work with the example like:
#Repository public interface TestESearchRes extends
ElasticsearchRepository<Test,Long>,ComService
When run the server I got:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'ESearchServiceImpl': Unsatisfied dependency
expressed through field 'testESearchRes'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'testESearchRes': Initialization of bean failed; nested exception
is java.lang.AbstractMethodError
In ESearchServiceImpl:
#Autowired
private TestESearchRes testESearchRes;
But when I use spring-data-elasticsearch 1.3.0.RELEASE .It's ok.But can not connect to es
Can anyone help me.Thanks!

may be you can try up spring to 5.5.0,i have a problem like this,and up my spring version

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.

Error with Spring security framework 2.6.4 (NoSuchMethodError for getInterfaceMethodIfPossible)

After the update to Spring boot 2.6.4, I get this error while i try to call my rest controllers:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Unsatisfied dependency expressed through method 'setFilterChainProxySecurityConfigurer' parameter 1; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is java.lang.NoSuchMethodError: 'java.lang.reflect.Method org.springframework.util.ClassUtils.getInterfaceMethodIfPossible(java.lang.reflect.Method, java.lang.Class)'
The problem does not occur until 2.6.3
I tried to add:
#EnableWebSecurity
#EnableWebMvc
To my WebSecurityConfigurerAdapter class, but that produces no difference
Spring Boot 2.6.4 should be used with Spring Framework 5.3.16 but you are using an earlier version. You need to update your Maven or Gradle configuration to correct this. I’d recommend using Spring Boot’s dependency management to keep versions in sync.
Upgrading spring-core version to 5.3.16 solved this issue.

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

Cache Busting in Spring Boot + Thymeleaf application

I read spring boot documentation and it seems that if I am using Thymeleaf, I can just add the following to my application.properties file to achieve cache busting:
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**
But it doesn't work!
This is the error that I see:
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.autoconfigure.web.ResourceProperties org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.resourceProperties; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.resources.CONFIGURATION_PROPERTIES': Could not bind properties to [unknown] (target=spring.resources, ignoreInvalidFields=false, ignoreUnknownFields=false, ignoreNestedProperties=false); nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'chain[strategy][fixed][version]' of bean class [org.springframework.boot.autoconfigure.web.ResourceProperties]: Cannot access indexed value in property referenced in indexed property path 'chain[strategy][fixed][version]'; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'chain[strategy][fixed][version]' of bean class [org.springframework.boot.autoconfigure.web.ResourceProperties]: Bean property 'chain[strategy][fixed][version]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
What am I missing?
The problem was with the version of spring boot I was using. Spring Boot 1.2 doesn't have any such properties while 1.3 does.

Resources