spring-boothibernatemysql-8.0hibernate-5.xgrails-3.1

Updating Grails 3.1 to use Hibernate 5.3


I'm upgrading my Grails 3.1 application to use MySQL 8. To use the "MySQL8Dialect," I need to update to Hibernate 5.3.

However, I'm encountering the following error when I run the app:

ERROR org.springframework.boot.SpringApplication - Application startup failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceInitializedPublisher': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.context.ApplicationContext org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.applicationContext; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.(Ljava/util/Collection;)V

Does anyone know what might be happening and how to resolve it?

My changes on application.yml:

dataSource:
    driverClassName: com.mysql.cj.jdbc.Driver
    dialect: org.hibernate.dialect.MySQL8Dialect

My changes on build.gradle:

compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core:5.3.34.Final"
compile "org.hibernate:hibernate-ehcache:5.3.34.Final"
runtime "mysql:mysql-connector-java:8.0.33"

Solution

  • I should remove the "dialect" from datasource in the application.yml!

    I was able to do it with this changes:

    build.gradle:

    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.1.0.Final"
    compile "org.hibernate:hibernate-ehcache:5.1.0.Final"
    runtime "mysql:mysql-connector-java:8.0.32"
    

    application.yml:

    dataSource:
        driverClassName: com.mysql.cj.jdbc.Driver