jbossjboss-eap-6grails-3.0hibernate-5.xjboss-logging

Grails 3.1.5, Hibernate 5, on JBoss throw NoSuchMethodError org.jboss.logging.Logger.debugf


In Grails 3.1.5 with Hibernate5 plugin I cannot deploy to JBoss EAP 6.4.0.GA.

I get:

NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V

I believe the issue is because Hibernate 5 has a dependency on jboss-logging 3 and even though I've included jboss-logging 3 in my build.gradle file, when I deploy to JBoss I think it's still using an earlier version of jboss-logging which does not include the new "f" methods, i.e. debugf().

How can I get a Grails 3 and Hibernate 5 app to deploy successfully on JBoss EAP 6.4.0?

My build.gradle file is:

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:5.0.4"
        classpath "org.grails.plugins:views-gradle:1.0.4"
        classpath "org.jboss.logging:jboss-logging:3.3.0.Final"
    }
}

version ...
group ...

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin: "war"
apply plugin: "org.grails.grails-web"
apply plugin: "org.grails.grails-gsp"
apply plugin:"asset-pipeline"
apply plugin: "org.grails.plugins.views-json"

ext {
    grailsVersion = project.grailsVersion
    gradleWrapperVersion = project.gradleWrapperVersion
}

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}

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-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    provided "org.springframework.boot:spring-boot-starter-tomcat"
    testCompile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-dependencies"
    compile "org.grails:grails-web-boot"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:views-json"

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

    console "org.grails:grails-console"
    profile "org.grails.profiles:web:3.1.5"
    runtime "org.grails.plugins:asset-pipeline"
    runtime "com.h2database:h2"

    runtime files('grails-app/lib/ojdbc7.jar', 'grails-app/lib/xdb6.jar')
    compile files('grails/src/java')

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

    testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:2.52.0"
    testRuntime "org.seleniumhq.selenium:selenium-support:2.52.0"

    console "org.grails:grails-console"

    runtime "org.jboss.logging:jboss-logging:3.3.0.Final"
}

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

assets {
    minifyJs = false // This will probably break dependency injection in our AngularJs artifacts that use DI.
    minifyCss = true
}

Solution

  • JBoss EAP 6.4 uses Hibernate 4.x. I wouldn't advise mixing versions of the JPA provider. You'd likely need to exclude the JPA subsystem from the deployment to ensure Hibernate 4 dependencies don't get included. You might need to explicitly exclude the JPA API dependencies too since EAP 6 is a Java EE 6 container and Hibernate 5 is for JPA 2.1 which is part of Java EE 7.

    If you've sorted out those issues then you'll also need to exclude the jboss-logging dependency from being added to your deployment. With EAP 6.4 you can set an attribute in the logging subsystem which will affect all deployments. Change the add-logging-api-dependencies attribute to false and include the version of jboss-logging required in your deployment.

    /subsystem=logging:write-attribute(name=add-logging-api-dependencies, value=false)
    

    If you want only a single deployment to ignore the dependency, then you could use a jboss-deployment-structure.xml to exclude the dependency or the logging subsystem.