Spring boot (1.3.6) + Hibernate(5.2.1) No qualifying bean of type [org.hibernate.SessionFactory] found for dependency: - spring-boot

While moving into micro-services from monolithic application, upon creating the micro-services using Spring boot (1.3.6) + Hibernate(5.2.1) we got an exception
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.hibernate.SessionFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}.
But the same source code is running on hibernate(4.3.11). Please find the source code on
https://github.com/pandiaraj2/Spring-boot-1.3.6-Hibernate-5.2
What do I need to do to resolve this error?

Spring Boot 1.3.6 uses Spring 4.2.x, which doesn't support Hibernate 5.2. You also have to upgrade Spring to 4.3, e.g. by adding the following property in your pom.xml:
<properties>
<spring.version>4.3.1.RELEASE</spring.version>
</properties>
But it still might be, that some of the autoconfigurations are not working, because full Hibernate support in Spring Boot will only be introduced in Spring Boot 1.4, which is still in release candidate.

i guess you need to add #EnableJpaRepositories annotation on your main class DtcmwsApplication and also need to remove exclusion for hibernate-entitymanager

Related

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.

How to fix "Consider defining a bean of type 'org.jooq.DSLContext' in your configuration." after update to jOOQ 3.15.0

In my Vaadin and Spring Boot application, I have updated from jOOQ 3.14.12 to 3.15.0. After this update my application is not starting up again. This is the error I get:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in org.komunumo.data.service.MemberService required a bean of type 'org.jooq.DSLContext' that could not be found.
Action:
Consider defining a bean of type 'org.jooq.DSLContext' in your configuration.
I don't understand why I have to define this bean, because with jOOQ 3.14.12 I did not have to. As far as I know, this is done by JooqAutoConfiguration automatically.
Spring Boot 2.6 answer
With Spring Boot 2.6, this issue no longer reproduces, see https://github.com/spring-projects/spring-boot/issues/26439
Spring Boot 2.5 answer
Starting from jOOQ 3.15.0, jOOQ ships with a built-in R2DBC dependency. Spring Boot 2.5 is not yet aware of this, and as such, you'll have to explicitly exclude R2dbcAutoConfiguration (not R2dbcDataAutoConfiguration!) from your spring boot application (unless you're using R2DBC with jOOQ, of course):
#SpringBootApplication(exclude = { R2dbcAutoConfiguration.class })
Note, you may see the following error message:
No qualifying bean of type 'org.jooq.DSLContext' available: expected at least 1 bean which qualifies as autowire candidate.
Which I'm adding here, because otherwise, people might not find this answer from Google.

Unable to Autowire brave.Tracer inside Spring boot Application

I am working on Spring boot application and I tried to Autowire Tracer object to get the traceId, but its raised the following exception. why??
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'brave.Tracer' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
I used the Tracer in a lot of projects and its always working with no issues!!
Spring boot container is not able to resolve the implementation of your autowired interface in this case. Please annotate your implementation class with spring stereotype annotations.
For e.g We provide #Reposiory for dao classes, #Service for service classes & #Component as a generic one. This will solve your problem. If you still face any issues, Just share your code snippet.

spring statemachine data jpa sample issues

I am trying to get the spring statemachine data jpa sample working and I am unable to. I have created a sample github project here. So far, I have only added the necessary dependencies and getting this error:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.statemachine.data.StateRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound (DefaultListableBeanFactory.java:1493)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency (DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency (DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject (AutowiredAnnotationBeanPostProcessor.java:585)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject (InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues (AutowiredAnnotationBeanPostProcessor.java:366)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean (AbstractAutowireCapableBeanFactory.java:1264)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:483)
Maybe you already figured this out but you're missing jpa libs. Those can be added i.e. using spring-boot-starter-data-jpa

Use CDI ConversationScoped beans in Spring Controllers

I'm trying to make webapp which should use thymeleaf with spring controllers. But I'd like to have some CDI ConversationScoped beans injected into my Spring controller. For now I managed to configure CDI with my Spring application I when I tried to incject CDI bean into my controller it seems to work fine, but when I tried to inject Conversation bean it fails with error:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [javax.enterprise.context.Conversation] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#javax.inject.Inject()}
In CDI 1.0 the conversation scope is tied to JSF. If you're not using JSF you won't be able to access the conversation scope. You could create another scope which mimics the conversation scope though.

Resources