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

(mike petrakis) #1


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: > 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


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.(

at org.gradle.util.LineBufferingOutputStream.(

at org.gradle.util.LinePerThreadBufferingOutputStream$1$

at org.gradle.util.LinePerThreadBufferingOutputStream$1$

at Method)

at org.gradle.util.LinePerThreadBufferingOutputStream$1.initialValue(

at org.gradle.util.LinePerThreadBufferingOutputStream$1.initialValue(

at java.lang.ThreadLocal.setInitialValue(

at java.lang.ThreadLocal.get(

at org.gradle.util.LinePerThreadBufferingOutputStream.getStream(

at org.gradle.util.LinePerThreadBufferingOutputStream.flush(

at sun.nio.cs.StreamEncoder.implFlush(

at sun.nio.cs.StreamEncoder.flush(


at java.util.logging.StreamHandler.flush(

at java.util.logging.ConsoleHandler.close(

at java.util.logging.LogManager.resetLogger(

at java.util.logging.LogManager.reset(

at java.util.logging.LogManager$

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/


//includeTestsMatching “Functional

//includeTestsMatching “.functional.


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

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

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

systemProperty “geb.env”, driver

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

// systemProperty “”, “

} }

test {

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

enabled = false

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

task wrapper(type: Wrapper) {

gradleVersion = ‘1.10’ }

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



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.