Grails 2.2 to 2.3 - Error running forked test-app: Could not load grails build listener class
Asked Answered
R

1

7

I'm migrating my project from grails 2.2 to 2.3 and when I do test-app (on IDEA 12.1.6), I got this error

| Error Error running forked test-app: Could not load grails build listener class
java.lang.RuntimeException: Could not load grails build listener class
    at org.codehaus.groovy.grails.cli.support.GrailsBuildEventListener.addGrailsBuildListener(GrailsBuildEventListener.java:258)
    at org.codehaus.groovy.grails.cli.support.GrailsBuildEventListener.loadGrailsBuildListeners(GrailsBuildEventListener.java:106)
    at org.codehaus.groovy.grails.cli.support.GrailsBuildEventListener.initialize(GrailsBuildEventListener.java:73)
    at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProjectClassExecutor.createEventListener(ForkedGrailsProjectClassExecutor.groovy:102)
    at org.codehaus.groovy.grails.cli.fork.testing.ForkedGrailsTestRunner.createInstance(ForkedGrailsTestRunner.groovy:93)
    at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProjectClassExecutor.initializeProjectInstance(ForkedGrailsProjectClassExecutor.groovy:85)
    at org.codehaus.groovy.grails.cli.fork.ForkedGrailsProjectClassExecutor.run(ForkedGrailsProjectClassExecutor.groovy:72)
    at org.codehaus.groovy.grails.cli.fork.testing.ForkedGrailsTestRunner.main(ForkedGrailsTestRunner.groovy:75)
Caused by: java.lang.ClassNotFoundException: org.jetbrains.groovy.grails.rt.GrailsIdeaTestListener
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:648)
    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:758)
    at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:746)
    at org.codehaus.groovy.grails.cli.support.GrailsBuildEventListener.addGrailsBuildListener(GrailsBuildEventListener.java:255)
    ... 7 more
| Error Error running forked test-app: Could not load grails build listener class
| Error Forked Grails VM exited with error

My BuildConfig.groovy look like this:

grails.servlet.version = "3.0" 
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.work.dir = "target/work"
grails.project.target.level = 1.6
grails.project.source.level = 1.6

grails.project.fork = [
    test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
    console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256]
]

grails.project.dependency.resolver = "maven" // or ivy

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "error" 
    checksums true 
    legacyResolve false 

    repositories {
        inherits true // Whether to inherit repository definitions from plugins

        grailsPlugins()
        grailsHome()
        mavenLocal()
        grailsCentral()
        mavenCentral()
    }

    dependencies {
        runtime 'mysql:mysql-connector-java:5.1.24'
    }

    plugins {
        build ":tomcat:7.0.42"

        compile ":scaffolding:2.0.1"
        compile ':cache:1.1.1'

        runtime ":hibernate:3.6.10.2" // or ":hibernate4:4.1.11.2"
        runtime ":jquery:1.10.2"
        runtime ":resources:1.2.1"
    }
}

What's wrong ?

Ranitta answered 27/10, 2013 at 0:23 Comment(5)
Have you also tried without forked JVM?Tintoretto
Yeah "unforked" it works well, but I also wanna use the forked modeRanitta
Any update on this? Was a solution ever found?Dessertspoon
I just try with 2.3.4 and I still have the exact same problemRanitta
There's a issue open at jetbrain youtrack.jetbrains.net/issue/IDEA-61453Ranitta
M
8

In order to take advantage of the new Grails fork test functionality in IntelliJ at the moment, you need to find the grails-rt.jar file under your IntelliJ installation directory, and copy it to your grails project lib dir, or make it available to your grails application via the class path.

In my case, on Mac OS X, the grails-rt.jar file was located in:

/Applications/IntelliJ\ IDEA\ 13.app/plugins/Grails/lib/grails-rt.jar

and I copied this file to ~/MyGrailsApp/lib.

Modla answered 11/3, 2014 at 21:21 Comment(4)
Thanks, I'll try this as soon as possible and I'll give you feedback ;)Ranitta
This worked for me but it seems like it should be brought up in a JIRA ticket or bug report for intellij.Gearard
It looks like there are at least a couple of tickets: youtrack.jetbrains.com/issue/IDEA-115855, and youtrack.jetbrains.com/issue/IDEA-115097Modla
As noted in the IDEA ticket @RyanGrow mentioned, you can set: grails.project.fork = [ test: false, ... ] in your BuildConfig as a workaround.Sect

© 2022 - 2024 — McMap. All rights reserved.