Updating Grails 3.1 to use Hibernate 5.3

83 Views Asked by At

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"

build.gradle full:

buildscript {
    ext {
        grailsVersion = project.grailsVersion
    }
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.5.0'
        classpath "org.grails.plugins:hibernate5:7.0.7"
    }
}

plugins {
    id "io.spring.dependency-management" version "0.5.2.RELEASE"
    id "ua.eshepelyuk.ManifestClasspath" version "1.0.0"
}

version "2.3.1"
group "app"

apply plugin: "spring-boot"
apply plugin: "war"
apply plugin: "asset-pipeline"
apply plugin: 'idea'
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"

ext {
    grailsVersion = project.grailsVersion
    gradleWrapperVersion = 2.9
}

assets {
    minifyJs = false
    minifyCss = true
    includes = ["fonts/*"]
}

repositories {
    maven { url "https://repo.grails.org/grails/core" }
    maven { url "https://repo.maven.apache.org/maven2" }
    maven { url "http://jasperreports.sourceforge.net/maven2" }
}

dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
    }
    applyMavenExclusions false
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-dependencies"
    compile "org.grails:grails-web-boot"

    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.3.34.Final"
    compile "org.hibernate:hibernate-ehcache:5.3.34.Final"

    compile "org.grails.plugins:cache"

    compile "org.grails.plugins:spring-security-core:3.1.1"
    compile "org.grails.plugins:spring-security-rest:2.0.0.M2"

    compile 'com.lowagie:itext:2.1.7.js2'
    compile ('net.sf.jasperreports:jasperreports:6.2.1') {
        exclude module: 'olap4j'
    }

    compile "org.grails.plugins:excel-export:2.1"
    compile "org.grails.plugins:mail:2.0.1"

    compile "com.google.maps:google-maps-services:2.1.2"

    runtime "org.grails.plugins:asset-pipeline"
    runtime "mysql:mysql-connector-java:8.0.33"

    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"

    // Note: It is recommended to update to a more robust driver (Chrome, Firefox etc.)
    testRuntime 'org.seleniumhq.selenium:selenium-htmlunit-driver:2.44.0'

    console "org.grails:grails-console"
}

task wrapper(type: Wrapper) {
    gradleVersion = gradleWrapperVersion
}
0

There are 0 best solutions below