Error creating bean with name 'entityManagerFactory' : org/hibernate/dialect/PostgreSQL82Dialect
Asked Answered
C

2

10

I'm migrating the spring boot parent version from 2.5.12 to 3.0.6 and I faced many issues that I could fix but I struggle with this one :

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/PostgreSQL82Dialect


Caused by: java.lang.NoClassDefFoundError: org/hibernate/dialect/PostgreSQL82Dialect
    at com.vladmihalcea.hibernate.type.HibernateTypesContributor.contribute(HibernateTypesContributor.java:34)
    at org.hibernate.boot.internal.MetadataBuilderImpl.applyTypes(MetadataBuilderImpl.java:296)

my pom.xml (only dependencies affected):

<!-- versions -->
    <hibernate-core.version>6.2.5.Final</hibernate-core.version>
    <hibernate-types.version>2.16.3</hibernate-types.version>
    <postgresql.version>42.5.4</postgresql.version>
    <spring.boot.version>3.0.6</spring.boot.version>
    
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
      <version>${spring.boot.version}</version>
    </dependency>
    <dependency>
      <groupId>com.vladmihalcea</groupId>
      <artifactId>hibernate-types-52</artifactId>
      <version>${hibernate-types.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>${hibernate-core.version}</version>
      <scope>compile</scope>
    </dependency>

application properties :


  jpa:
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect

java version : 17

Caceres answered 16/6, 2023 at 19:44 Comment(2)
is that issue resolved? If yes, please share the steps that you have followed!Alwyn
issue still occurs for spring-boot 3.2.3 with java 17 can you help if it has resolved the issue.Slideaction
T
18

Take note that you are still using hibernate-types52 which refers to previous major hibernate 5+. You should refer to the latest hibernate-types60 dependency to fully migrate to hibernate 6+. As of time, you can use the following:

<dependency>
        <groupId>com.vladmihalcea</groupId>
        <artifactId>hibernate-types-60</artifactId>
        <version>2.21.1</version>
</dependency>
Tessin answered 17/7, 2023 at 19:52 Comment(1)
I am MariaDB witch is well configured in properties file when using Springboot-2.7 In Springboot 3.2.5 this error "java.lang.NoClassDefFoundError: org/hibernate/dialect/PostgreSQL82Dialect" appears suddently and i can not understand why this dependency "hibernate-types-52" is causing this error !!! But after upgrading to "hibernate-types-60" it get rid of the PostgresSQL.... Thanks a lot...Permeability
S
1

Upgraded to java 21 and Springboot 3.3.0 faced similar issues and the solution was replacing the hibernate-types-52 dependency with the newer version of the project which has been renamed to hypersistence-utils. Link to project documentation hypersistence-utils

<dependency>
   <groupId>io.hypersistence</groupId>
   <artifactId>hypersistence-utils-hibernate-63</artifactId>
   <version>3.7.6</version>
</dependency>
Standin answered 24/6 at 11:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.