javahibernategrailsgrails-orm

Caused by: java.lang.ClassNotFoundException: org.grails.orm.hibernate5.support.GrailsOpenSessionInViewInterceptor


I am trying to update my grails 3 app to grails 4. When I run the app, i get the following error.

java.lang.NoClassDefFoundError: org/grails/orm/hibernate5/support/GrailsOpenSessionInViewInterceptor
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        at com.cmt.multitenant.CmtMultiTenantGrailsPlugin$_doWithSpring_closure1.doCall(CmtMultiTenantGrailsPlugin.groovy:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:101)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:263)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1041)
        at groovy.lang.Closure.call(Closure.java:405)
        at groovy.lang.Closure.call(Closure.java:399)
        at grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:759)
        at grails.spring.BeanBuilder.beans(BeanBuilder.java:588)
        at grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:531)
        at org.grails.plugins.DefaultGrailsPlugin.doWithRuntimeConfiguration(DefaultGrailsPlugin.java:543)
        at org.grails.plugins.AbstractGrailsPluginManager.doRuntimeConfiguration(AbstractGrailsPluginManager.java:166)
        at grails.boot.config.GrailsApplicationPostProcessor.postProcessBeanDefinitionRegistry(GrailsApplicationPostProcessor.groovy:171)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:275)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:125)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:96)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:456)
        at grails.boot.GrailsApp.run(GrailsApp.groovy:443)
        at grails.boot.GrailsApp$run.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:135)
        at com.cmt.warranty.Application.main(Application.groovy:8)
Caused by: java.lang.ClassNotFoundException: org.grails.orm.hibernate5.support.GrailsOpenSessionInViewInterceptor
        at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
        ... 45 common frames omitted

my build.gradle is

 dependencies {
//runtimeOnly("org.springframework.boot:spring-boot-devtools")
 runtimeOnly("org.grails:grails-datastore-gorm-support:$gormVersion")

implementation "org.springframework.boot:spring-boot-starter-logging"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.grails:grails-web-boot"
implementation "org.grails:grails-web-gsp"
implementation "org.grails.plugins:cache"
implementation "org.grails.plugins:scaffolding"
implementation "org.grails.plugins:views-json-templates"
implementation "org.grails:grails-datastore-gorm:$gormVersion"

testImplementation "org.grails:grails-web-testing-support"
testImplementation "org.springframework.boot:spring-boot-starter-test"

// Sub-project dependencies

compile project(":wt-core")
compile "com.cmt:gt3-assets:3.1.16"
compile "com.cmt:wt-shell:1.0", {
    transitive = false
}

//Spring
compile 'org.grails.plugins:spring-security-core:4.0.4'
implementation 'org.springframework.security:spring-security-acl:5.2.2.RELEASE'


//AWS
compile "org.grails.plugins:aws-sdk-s3:$awsSdkS3Version"
compile "com.amazonaws:aws-java-sdk-s3:1.11.375"

//CMT Plugins
compile "org.grails.plugins:cmt-multitenant:2.5.2-SNAPSHOT"
compile "org.grails.plugins:cmt-command:0.3-SNAPSHOT"
compile "org.grails.plugins:cmt-security:3.2.3-SNAPSHOT"


//Quartz Jobs
compile 'org.grails.plugins:quartz:2.0.13'

//Grails Plugins
compile 'org.grails.plugins:mail:3.0.0'
compile "io.github.gpc:asynchronous-mail:3.0.0"
compile 'org.grails.plugins:excel-export:2.1'
implementation 'com.jameskleeh:excel-builder:0.4.4'
compile "org.grails.plugins:database-migration:3.1.0.BUILD-SNAPSHOT"
compile 'org.grails.plugins:converters:4.0.0'

compile "org.grails:grails-datastore-rest-client:6.1.12.BUILD-SNAPSHOT"
//compile 'org.grails:grails-datastore-rest-client:5.0.0.RC2'

//unable to resolve class org.apache.poi.ss.usermodel....
implementation 'org.apache.poi:poi:4.1.2'
implementation 'org.apache.poi:poi-ooxml:4.1.2'


//unable to resolve class org.jasig.cas.client.authentication.AttributePrincipal
//unable to resolve class org.springframework.security.cas.authentication.CasAuthenticationToken
implementation 'org.springframework.security:spring-security-cas:5.5.1'
implementation 'org.jasig.cas.client:cas-client-core:3.6.0'

//PDF
compile 'org.apache.pdfbox:pdfbox:2.0.24'

//LiquidBase
compile 'org.liquibase:liquibase-core:3.8.0'

//unable to resolve class org.apache.commons.io.IOUtils
compile 'commons-io:commons-io:2.10.0'

//https://stackoverflow.com/questions/71932451/grails-4-static-type-checking-error-only-for-date-objects
implementation "org.codehaus.groovy:groovy-dateutil:2.5.6"

//Tests
testCompile "org.grails.plugins:build-test-data:3.3.0.RC2"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.grails:grails-web-testing-support"
testCompile "org.grails.plugins:geb:1.1.2"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:2.47.1"
testCompile "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"

}


Gradle 5.0

Build time:   2018-11-26 11:48:43 UTC
Revision:     7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987

Kotlin DSL:   1.0.4
Kotlin:       1.3.10
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_302 (Amazon.com Inc. 25.302-b08)
OS:           Mac OS X 13.3.1 x86_64

Solution

  • Turns out I had a custom plugin that had a conflicting version of hibernate5