I started getting some mysterious failures in my test task when I upgraded to a newer version of the spring & neo4j frameworks. Basically the spring context was unable to initialize the beans, but was failing deep in the java stack with ‘java.lang.VerifyError: Uninitialized object exists on backward branch 60’. I struggled to figure out what the problem was since I was able to run the tests through intellij without an issue.
Finally I found that if I overwrote the test task within my build file the context would somehow magically get corrected and the test suite ran without a problem. Is there any way I can figure out what is the difference between the default task’s environment and the environment that is getting passed when I have overridden the task locally?
exerpt of build.gradle:
project(':graph-web') {
apply plugin: 'war'
apply plugin: 'tomcat'
configurations {
wsDocAnnotationProcessor
}
war {
archiveName = 'product-graph.war'
}
// Why does adding this work?
task test(type: Test, dependsOn: testClasses, overwrite: true) {
}
sourceSets.main.resources.srcDir "src/main/webapp"
dependencies {
compile project(':graph-business')
compile "org.springframework:spring-web:$springVersion"
compile "org.springframework:spring-webmvc:$springVersion"
compile "org.springframework:spring-aspects:${springVersion}"
compile 'javax.servlet:javax.servlet-api:3.0.1'
compile 'com.backcountry:jsondoc-springmvc:1.0.2-SNAPSHOT'
compile 'org.hibernate:hibernate-validator:4.2.0.Final'
runtime "com.fasterxml.jackson.core:jackson-core:2.1.0"
runtime "com.fasterxml.jackson.core:jackson-databind:2.1.0"
testCompile "com.jayway.jsonpath:json-path:0.8.1"
testCompile 'com.google.code.gson:gson:2.2.4'
testCompile "org.neo4j:neo4j-kernel:$neo4jVersion:tests"
wsDocAnnotationProcessor 'org.versly:versly-wsdoc:1.0-SNAPSHOT'
def tomcatVersion = '7.0.35'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
tomcat "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
}