Search code examples
spock

Resolving org.spockframework.util.InternalSpockError


I am getting a lot of errors of the form

> Task :test

ConfigResourceSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.ExceptionInInitializerError at NativeConstructorAccessorImpl.java:-2
            Caused by: com.google.common.util.concurrent.UncheckedExecutionException at LocalCache.java:2055
                Caused by: com.datastax.oss.driver.api.core.AllNodesFailedException at AllNodesFailedException.java:141

DefaultTenancySpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

SchemaManagementSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

CQRSResourceSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.ExceptionInInitializerError at NativeConstructorAccessorImpl.java:-2
            Caused by: com.google.common.util.concurrent.UncheckedExecutionException at LocalCache.java:2055
                Caused by: com.datastax.oss.driver.api.core.AllNodesFailedException at AllNodesFailedException.java:141

ETLResourceSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

EntityDeleteSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

EntitySpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

EntityUpsertSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

NamespaceSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

CSVSchemaDiscoverySpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
         Caused by: java.lang.ExceptionInInitializerError at NativeConstructorAccessorImpl.java:-2
            Caused by: com.google.common.util.concurrent.UncheckedExecutionException at LocalCache.java:2055
                Caused by: com.datastax.oss.driver.api.core.AllNodesFailedException at AllNodesFailedException.java:141

EntityDefinitionSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

EntityLookupSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

EntityUpdateSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

ProtectedResourceSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

EntityMutationValidatorSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

CQRSExceptionMapperSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.ExceptionInInitializerError at NativeConstructorAccessorImpl.java:-2
            Caused by: com.google.common.util.concurrent.UncheckedExecutionException at LocalCache.java:2055
                Caused by: com.datastax.oss.driver.api.core.AllNodesFailedException at AllNodesFailedException.java:141

TenantSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
         Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

EntityFilterQuerySpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.ExceptionInInitializerError at NativeConstructorAccessorImpl.java:-2
            Caused by: com.google.common.util.concurrent.UncheckedExecutionException at LocalCache.java:2055
                Caused by: com.datastax.oss.driver.api.core.AllNodesFailedException at AllNodesFailedException.java:141

EntityTruncateSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

OrchestrationResourceSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

EntityDefinitionValidatorSpec > initializationError FAILED
    org.spockframework.util.InternalSpockError at PlatformSpecRunner.java:80
        Caused by: java.lang.NoClassDefFoundError at NativeConstructorAccessorImpl.java:-2

33 tests completed, 21 failed, 8 skipped

I suspect there something central in configuration that is causing this, and it's a result of upgrading our code base from Java 8 to Java 11, where I had to change a lot of dependencies in Gradle for things to work with Java 11. Consequently, I have also updated to the latest Groovy, Spock, etc.

I have never used Spock, as I am just cleaning up our mono-repo.

Can anyone suggest some basic things I should check related to Spock, Gradle, etc.?

Generally my Gradle dependencies look like

// mandatory dependencies for using Spock from https://github.com/spockframework/spock-example/blob/master/build.gradle

testImplementation platform("org.apache.groovy:groovy-bom:4.0.10")
testImplementation "org.apache.groovy:groovy"
testImplementation "org.apache.groovy:groovy-json"

testImplementation platform("org.spockframework:spock-bom:2.3-groovy-4.0")
testImplementation "org.spockframework:spock-core"

Solution

  • This is not actually a Spock error in that case, even with InternalSpockError being the top cause.

    If you look at the test report in build/reports/tests, you should get the full stacktrace shown and maybe more helpful info.

    The place where this exception is thrown is, when Spock tries to instantiate your specification class and that fails. So you need to open the test report and go through the stacktrace to find where your class is failing to instantiate and why. There is not much Spock can do about that other than to report it as it does.