Getting 'java.lang.NoClassDefFoundError' when running Geb tests while excluding unit or integration tests


(mike petrakis) #1

Hi,

I am using Gradle 1.10 to run Geb tests. Without using any filtering or excluding/including, the Geb tests run fine but the task attempts to run the unit and integration tests as well.

If I use either the new filtering functionality or the ‘include’ or ‘exclude’ to include just the Geb tests or to exclude the unit and integration tests, I get the error on importing the Geb pages in the test. It is as if it cannot find the pages for the imports.

Here is the error:

test.groovy.functional.tests.store.StoreLocatorFunctionalTest > search for stores by postal code should return results FAILED

geb.driver.DriverCreationException at StoreLocatorFunctionalTest.groovy:10

Caused by: java.lang.NoClassDefFoundError at StoreLocatorFunctionalTest.groovy:10

geb.driver.DriverCreationException

Caused by: java.lang.NoClassDefFoundError Exception in thread “Thread-0” java.lang.NoClassDefFoundError: Could not initialize class org.gradle.internal.SystemProperties

at org.gradle.util.LineBufferingOutputStream.(LineBufferingOutputStream.java:44)

at org.gradle.util.LineBufferingOutputStream.(LineBufferingOutputStream.java:36)

at org.gradle.util.LinePerThreadBufferingOutputStream$1$1.run(LinePerThreadBufferingOutputStream.java:35)

at org.gradle.util.LinePerThreadBufferingOutputStream$1$1.run(LinePerThreadBufferingOutputStream.java:33)

at java.security.AccessController.doPrivileged(Native Method)

at org.gradle.util.LinePerThreadBufferingOutputStream$1.initialValue(LinePerThreadBufferingOutputStream.java:33)

at org.gradle.util.LinePerThreadBufferingOutputStream$1.initialValue(LinePerThreadBufferingOutputStream.java:30)

at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:160)

at java.lang.ThreadLocal.get(ThreadLocal.java:150)

at org.gradle.util.LinePerThreadBufferingOutputStream.getStream(LinePerThreadBufferingOutputStream.java:47)

at org.gradle.util.LinePerThreadBufferingOutputStream.flush(LinePerThreadBufferingOutputStream.java:80)

at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)

at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)

at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)

at java.util.logging.StreamHandler.flush(StreamHandler.java:242)

at java.util.logging.ConsoleHandler.close(ConsoleHandler.java:115)

at java.util.logging.LogManager.resetLogger(LogManager.java:1014)

at java.util.logging.LogManager.reset(LogManager.java:1000)

at java.util.logging.LogManager$Cleaner.run(LogManager.java:242)

Here is the full Gradle script. I have commented out all of the filtering tests that I have tried. As is, this runs the Geb tests, but tries to run the integration and unit as well. When I try any of the filtering, I get the above error.

All of the tests have the type in the name, that was how I was trying to use the new filtering feature.

apply plugin: ‘groovy’ apply plugin: ‘eclipse’

sourceCompatibility = 1.7

repositories {

mavenCentral() }

configurations {

testCompile.transitive = true }

ext.drivers = [“firefox”, “chrome”,“ie”]

dependencies {

compile “org.codehaus.groovy:groovy-all:2.1.1”

compile fileTree(dir: ‘c:/lumbersts-3.1.0/lumberSite/src/main/webapp/WEB-INF/lib’, include: ‘*.jar’)

compile fileTree(dir: ‘c:/ApacheGroup/apache-tomcat-7.0.32/lib’, include: ‘*.jar’)

def seleniumVersion = “2.37.1”

testCompile “org.gebish:geb-spock:0.9.2”

testCompile “org.spockframework:spock-core:0.7-groovy-2.0”

drivers.each { driver ->

testCompile “org.seleniumhq.selenium:selenium-$driver-driver:$seleniumVersion”

}

testRuntime “org.seleniumhq.selenium:selenium-support:$seleniumVersion” }

sourceSets {

main {

groovy {

srcDirs = [‘c:/lumbersts-3.1.0/lumberSite/src/main/groovy’,‘c:/lumbersts-3.1.0/lumberSite/src/main/java’]

}

}

test {

groovy {

srcDirs = [‘c:/lumbersts-3.1.0/LumberGeb/src’,‘c:/lumbersts-3.1.0/lumberSite/src/test’]

}

} }

drivers.each { driver ->

task “${driver}Test”(type: Test) {

//exclude ‘/unit/

//exclude ‘/integration/

//include ‘/functional/

filter{

//includeTestsMatching “Functional

//includeTestsMatching “.functional.

}

testReportDir = reporting.file("$name/tests")

testResultsDir = file("$buildDir/test-results/$name")

systemProperty “geb.build.reportsDir”, reporting.file("$name/geb")

systemProperty “geb.env”, driver

// If you wanted to set the baseUrl in your build…

// systemProperty “geb.build.baseUrl”, “http://myapp.com

} }

test {

dependsOn drivers.collect { tasks["${it}Test"] }

enabled = false

//systemProperties “geb.build.reportsDir”: “$reportsDir/geb” }

task wrapper(type: Wrapper) {

gradleVersion = ‘1.10’ }

Here is the dir structure of the test class files: build -> classes - > test ->

integration

unit

test -> groovy - > functional

Thanks in advance for any suggestions. Please let me know if you need more info. Mike


(mike petrakis) #2

I figured it out. Gradle was pulling down guava-15.0.jar and I had version 12 for my website. Everything started working correctly once I removed the version 12 file.