spring-framework: Error creating bean entityManagerFactory with spring boot 3.1.0-RC2. ClassNotFoundException: PostgreSQL95Dialect
Affects: spring boot 3.1.0-RC2 I tried to update spring boot 3.0.5 -> 3.1.0-RC2 and got the following error:
2023-05-15T12:11:38.518+06:00 INFO 49951 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-05-15T12:11:38.524+06:00 ERROR 49951 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: org/hibernate/dialect/PostgreSQL95Dialect
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-6.0.8.jar:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.8.jar:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.8.jar:6.0.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.8.jar:6.0.8]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.8.jar:6.0.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.8.jar:6.0.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.8.jar:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1132) ~[spring-context-6.0.8.jar:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:907) ~[spring-context-6.0.8.jar:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[spring-context-6.0.8.jar:6.0.8]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733) ~[spring-boot-3.1.0-RC2.jar:3.1.0-RC2]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435) ~[spring-boot-3.1.0-RC2.jar:3.1.0-RC2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[spring-boot-3.1.0-RC2.jar:3.1.0-RC2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) ~[spring-boot-3.1.0-RC2.jar:3.1.0-RC2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294) ~[spring-boot-3.1.0-RC2.jar:3.1.0-RC2]
at com.arvgord.bankdemoserver.AppKt.main(App.kt:12) ~[main/:na]
Caused by: java.lang.NoClassDefFoundError: org/hibernate/dialect/PostgreSQL95Dialect
at org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.determineDatabaseDialectClass(HibernateJpaVendorAdapter.java:181) ~[spring-orm-6.0.8.jar:6.0.8]
at org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.buildJpaPropertyMap(HibernateJpaVendorAdapter.java:144) ~[spring-orm-6.0.8.jar:6.0.8]
at org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter.getJpaPropertyMap(HibernateJpaVendorAdapter.java:128) ~[spring-orm-6.0.8.jar:6.0.8]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:365) ~[spring-orm-6.0.8.jar:6.0.8]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.8.jar:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816) ~[spring-beans-6.0.8.jar:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.8.jar:6.0.8]
... 15 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.hibernate.dialect.PostgreSQL95Dialect
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
... 22 common frames omitted
I have the following application yaml:
spring:
profiles:
active: 'prod'
jpa:
database: postgresql
hibernate:
ddl-auto: none
show-sql: true
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect
datasource:
driver-class-name: ${POSTGRES_DRIVER:org.postgresql.Driver}
I see that the class PostgreSQL95Dialect no longer exists in Hibernate 6.2.2.Final but spring tries to load it even though I use PostgreSQLDialect
Issue moved from https://github.com/spring-projects/spring-data-jpa/issues/2952
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 5
- Comments: 27 (16 by maintainers)
Commits related to this issue
- Skip setting hibernate.dialect for hibernate 6 or above Versioned dialects are replaced with an unified dialect since 6.0 and removed since 6.2 This commit fix ClassNotFoundException for hibernate 6.... — committed to quaff/spring-framework by quaff 4 years ago
- Stop trying resolve dialect for hibernate 6 or above Versioned dialects are replaced with an unified dialect since 6.0 and removed since 6.2 This commit fix ClassNotFoundException for hibernate 6.2 F... — committed to quaff/spring-framework by quaff 4 years ago
@salehshehata-RL I had an issue alike and it was because I’ve upgraded
hibernateversion, but did not upgradehibernate-types(it washibernate-types-52). While it shall be:@mdeinum
is identical to
Both will be translated to properties
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialectSame issue with Spring Boot v3.1.0
Oh sorry, I must have clicked the wrong link
I set hibernate.dialect as you described but got the same issue. With database-platform: org.hibernate.dialect.PostgreSQLDialect it works fine
The problem is that you have written the properties wrong, a common thing when trying to override hibernate properties with yaml.
This is actually wrong, as anything under
propertiesare added as is to the hibernate JPA entitymanager. Instead you should have writtenThis will now override the property set by the
HibernateJpaProviderbased on thespring.jpa.databaseproperty with your explicitly configured one.