spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.3k stars 38k forks source link

Error creating bean entityManagerFactory with spring boot 3.1.0-RC2. ClassNotFoundException: PostgreSQL95Dialect #30488

Closed arvgord closed 1 year ago

arvgord commented 1 year ago

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

mdeinum commented 1 year ago

The problem is that you have written the properties wrong, a common thing when trying to override hibernate properties with yaml.

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

This is actually wrong, as anything under properties are added as is to the hibernate JPA entitymanager. Instead you should have written

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

This will now override the property set by the HibernateJpaProvider based on the spring.jpa.database property with your explicitly configured one.

arvgord commented 1 year ago

This will now override the property set by the HibernateJpaProvider based on the spring.jpa.database property with your explicitly configured one.

I set hibernate.dialect as you described but got the same issue. With database-platform: org.hibernate.dialect.PostgreSQLDialect it works fine

spring:
  jpa:
    database-platform: org.hibernate.dialect.PostgreSQLDialect
mdeinum commented 1 year ago

Hmm which is weird as that should work, the properties from the HibernateJpaVendorAdapter will only be applied if no other one has been applied before (with what you do). However using database-platform will indeed work as that results in setting the hibernate.dialect property as well (and should imho be preferred over database in this case).

quaff commented 1 year ago

The problem is that you have written the properties wrong, a common thing when trying to override hibernate properties with yaml.

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

This is actually wrong, as anything under properties are added as is to the hibernate JPA entitymanager. Instead you should have written

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

This will now override the property set by the HibernateJpaProvider based on the spring.jpa.database property with your explicitly configured one.

@mdeinum

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

is identical to

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

Both will be translated to properties spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

quaff commented 1 year ago

This will now override the property set by the HibernateJpaProvider based on the spring.jpa.database property with your explicitly configured one.

I set hibernate.dialect as you described but got the same issue. With database-platform: org.hibernate.dialect.PostgreSQLDialect it works fine

spring:
  jpa:
    database-platform: org.hibernate.dialect.PostgreSQLDialect

Because determineDatabaseDialectClass() will not be called if database-platform present. https://github.com/spring-projects/spring-framework/blob/d86cfc949d55b6dced27ce9435786412e20c9ce1/spring-orm/src/main/java/org/springframework/orm/jpa/vendor/HibernateJpaVendorAdapter.java#L140-L148

mdeinum commented 1 year ago

@quaff normally you would be right, however not in this case.

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

Leads to the spring.jpa.properties to have a Map under hibernate with another Map containing dialect. And as the elements under spring.jpa.properties are directly copied to the EntityManagerFactory JPA properties this isn't correct.

The output after loading this in the Map being used for the PropertySource the result is (the toString of the resulting Map:

{spring={jpa={properties={hibernate={dialect=foo.bar}}}}}

Where as

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

Will lead to a Map of properties under spring.jpa.properties with an element hibernate.dialect which will be copied to the EntityManagerFactory.

{spring={jpa={properties={hibernate.dialect=foo.bar}}}}

As you can see the output for both is different, where the first is wrong, the second is right. This is also an issue and question I answered numerous times on StackOverflow in the case of Yaml configuration.

You would be right if this was a property that was being bound to a Spring property or a Spring Boot @ConfigurationProperties however as the values are passed directly this is not the case.

@arvgord Setting hibernate.dialect and spring.jpa.database indeed won't work as it will still try to resolve the class, after that it won't be used, but the damage has already been caused.

quaff commented 1 year ago

@mdeinum I mean they are identical for spring boot yaml configuration, thanks for your elaboration.

mdeinum commented 1 year ago

@mdeinum I mean they are identical for spring boot yaml configuration, thanks for your elaboration.

As I pointed out they aren't as they are read and thus processed differently (see the output). There is already a warning about this (more or less) in the Spring Boot reference guide.

In short one of them will work the other won't.

quaff commented 1 year ago

@mdeinum I mean they are identical for spring boot yaml configuration, thanks for your elaboration.

As I pointed out they aren't as they are read and thus processed differently (see the output). There is already a warning about this (more or less) in the Spring Boot reference guide.

In short one of them will work the other won't.

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#data.sql.jpa-and-spring-data I didn't find warning, but this instead:

spring:
  jpa:
    properties:
      hibernate:
        "globally_quoted_identifiers": "true"
mdeinum commented 1 year ago

The warning is in the How To section. https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto.data-access.jpa-properties

However historically what is shown in the documentation simply didn't work due to the fact that they where processed differently. Apparently this has been fixed in more recent versions.

sdeleuze commented 1 year ago

When upgrading to Hibernate 6.2, we can indeed see that version specific dialects used in determineDatabaseDialectClass() have been removed for Derby, Informix and PostgreSQL, and other ones have been deprecated.

Screenshot from 2023-05-22 09-42-14

Now that Spring Boot is using Hibernate 6.2 by default, I am wondering if we should default to version-less dialects in case of ClassNotFoundException in Spring Framework 6.0.

I am also wondering if we plan to raise the Hibernate baseline in Spring Framework 6.1 (could help for #29549), and if we should just rely on Hibernate defaults for the selection of the dialect as of this version.

quaff commented 1 year ago

IMO, Hibernate baseline should be raised in Spring Framework 6 follow on migration from Java EE to Jakarta EE, and Spring Framework should determine dialect no more.

arvgord commented 1 year ago

Same issue with Spring Boot v3.1.0

sdeleuze commented 1 year ago

Likely fixed by #30288 so I close this issue as a duplicate.

jsiemssen commented 1 year ago

Is it correct that this has been closed? Because the issue https://github.com/spring-projects/spring-framework/issues/30288 also is marked as "duplicate" and had been closed a day before.

bclozel commented 1 year ago

@jsiemssen #30288 is not marked as duplicate for me and has been closed with https://github.com/spring-projects/spring-framework/commit/4c8f1910c82c340135082f3947f7dd9b611d6849.

jsiemssen commented 1 year ago

Oh sorry, I must have clicked the wrong link

salehshehata-RL commented 11 months ago

I have the same issue:

Caused by: java.lang.NoClassDefFoundError: org/hibernate/dialect/PostgreSQL82Dialect
    at com.vladmihalcea.hibernate.type.HibernateTypesContributor.contribute(HibernateTypesContributor.java:37) ~[hibernate-types-55-2.19.2.jar:?]
    at org.hibernate.boot.internal.MetadataBuilderImpl.applyTypes(MetadataBuilderImpl.java:296) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
    at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092) ~[?:?]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.applyTypeContributors(EntityManagerFactoryBuilderImpl.java:1355) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.applyMetamodelBuilderSettings(EntityManagerFactoryBuilderImpl.java:1336) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:275) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:193) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:63) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) ~[spring-beans-6.0.13.jar:6.0.13]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.13.jar:6.0.13]
    ... 16 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.dialect.PostgreSQL82Dialect
    at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[?:?]
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[?:?]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
    at com.vladmihalcea.hibernate.type.HibernateTypesContributor.contribute(HibernateTypesContributor.java:37) ~[hibernate-types-55-2.19.2.jar:?]
    at org.hibernate.boot.internal.MetadataBuilderImpl.applyTypes(MetadataBuilderImpl.java:296) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
    at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092) ~[?:?]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.applyTypeContributors(EntityManagerFactoryBuilderImpl.java:1355) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.applyMetamodelBuilderSettings(EntityManagerFactoryBuilderImpl.java:1336) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:275) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:193) ~[hibernate-core-6.2.13.Final.jar:6.2.13.Final]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:63) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.13.jar:6.0.13]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1817) ~[spring-beans-6.0.13.jar:6.0.13]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.13.jar:6.0.13]
    ... 16 more

Process finished with exit code 1

Spring boot version: 3.1.5 Application.properties

# default active profile is dev
spring.profiles.active=dev

# specify the logback config file to use
logging.config=classpath:logback-spring.xml

# disable the spring default flyway integration
spring.flyway.enabled=false

# our custom flyway properties
flyway.cleanDisabled=true
# TODO: name your schema
# NOTE: Do not use dashes in the name
# schema names, table names, column names, and etc should not have dashes '-' but instead use '_' if needed
# otherwise the term needs to be escaped with quotes in sql which is error prone, i.e. `my-dashed-table-name`
# NOTE: also use lowercase, because postgres actually coerces uppercase to lowercase anyways
# https://www.postgresql.org/docs/current/sql-syntax-lexical.html
flyway.schema=kotlin_spring

# specify the hibernate dialect
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.database-platform=org.hibernate.dialect.PostgreSQLDialect
# tell hibernate not to query the database for jdbc metadata, because we don't have a tenant context at boot
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
# tell hibernate to not do auto ddl
spring.jpa.properties.hibernate.hbm2ddl.auto=none
# tell hibernate to log sql, useful for development
spring.jpa.properties.hibernate.show_sql=false
bclozel commented 11 months ago

@salehshehata-RL this issue has been closed and resolved. If you believe this problem is not fixed, please create a new issue with a minimal repro project we can download or git clone to reproduce the problem.

PavelPolyakov commented 11 months ago

@salehshehata-RL I had an issue alike and it was because I've upgraded hibernate version, but did not upgrade hibernate-types (it was hibernate-types-52). While it shall be:

<dependency>
      <groupId>com.vladmihalcea</groupId>
      <artifactId>hibernate-types-60</artifactId>
      <version>2.21.1</version>
    </dependency>
PavithraPrakash62 commented 2 months ago
  | org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
user-service-1  |   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.0.jar:2.7.0]
user-service-1  |   at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.0.jar:2.7.0]
user-service-1  |   at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.0.jar:2.7.0]
user-service-1  |   at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.0.jar:2.7.0]
user-service-1  |   at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.0.jar:2.7.0]
user-service-1  |   at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.0.jar:2.7.0]
user-service-1  |   at com.example.tiktok.user.UserServiceApplication.main(UserServiceApplication.java:11) ~[classes/:na]
user-service-1  | Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
user-service-1  |   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1460) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1494) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:58) ~[spring-orm-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[spring-orm-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[spring-orm-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.20.jar:5.3.20]
user-service-1  |   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.20.jar:5.3.20]
user-service-1  |   ... 16 common frames omitted
user-service-1  | Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
user-service-1  |   at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:54) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:138) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ~[hibernate-core-5.6.9.Final.jar:5.6.9.Final]
user-service-1  |   ... 33 common frames omitted
user-service-1  | 
bclozel commented 2 months ago

@PavithraPrakash62 the stacktrace you are sharing is not related at all to this issue. Please reach out to StackOverflow with a minimal sample application if you'd like to get some help.

PavithraPrakash62 commented 2 months ago

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.20.jar:5.3.20] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.20.jar:5.3.20] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20] at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[spring-context-5.3.20.jar:5.3.20] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[spring-context-5.3.20.jar:5.3.20] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.20.jar:5.3.20] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.0.jar:2.7.0] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.0.jar:2.7.0] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.0.jar:2.7.0] at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.0.jar:2.7.0] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.0.jar:2.7.0] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.0.jar:2.7.0] same error its microservice and spring boot project i trying to dokerize