Jackson Databind Class Not Found in Build Environment

I’m getting a class not found exception for a Jackson Databind class that I’m explicitly adding a dependency to. I’ve verified that the method in question is in the version I’m importing. My code does not depend on Jackson but the Gradle-Dependency-Rules plugin does that I am trying to use. I’ve talked with the developer of the plugin and I don’t think this is an issue from their side. My only thought at this point is that Gradle or another dependency I’m importing in the buildscript block is bringing in a duplicate class. I’ve checked the buildEnvrionment output and things appear to be resolving correctly to the versions.

Is there a way to output the classpath of Gradle? Or can I package up the buildscript dependencies in some way so I can inspect the Jars?

Here is the last caused by of the exception. The previous are from Gradle’s project evaluation code.

Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.introspect.AnnotatedConstructor.getType()Lcom/fasterxml/jackson/databind/JavaType;
        at com.fasterxml.jackson.module.kotlin.KotlinNamesAnnotationIntrospector.hasCreatorAnnotation(KotlinModule.kt:81)
        at com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair.hasCreatorAnnotation(AnnotationIntrospectorPair.java:599)
        at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._addDeserializerConstructors(BasicDeserializerFactory.java:401)
        at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._constructDefaultValueInstantiator(BasicDeserializerFactory.java:325)
        at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findValueInstantiator(BasicDeserializerFactory.java:266)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:266)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:168)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:399)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:348)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:261)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:241)
        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
        at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:394)
        at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:3169)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3062)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2214)
        at nebula.plugin.resolutionrules.ResolutionRulesPlugin.parseJsonStream(plugin.kt:150)
        at nebula.plugin.resolutionrules.ResolutionRulesPlugin.rulesFromConfiguration(plugin.kt:94)
        at nebula.plugin.resolutionrules.ResolutionRulesPlugin$ruleSet$2.invoke(plugin.kt:37)
        at nebula.plugin.resolutionrules.ResolutionRulesPlugin$ruleSet$2.invoke(plugin.kt:30)
        at kotlin.SynchronizedLazyImpl.getValue(Lazy.kt:131)
        at nebula.plugin.resolutionrules.ResolutionRulesPlugin.getRuleSet(plugin.kt)
        at nebula.plugin.resolutionrules.ResolutionRulesPlugin$apply$1$1.execute(plugin.kt:64)

This is on Gradle 2.14.1 but I also saw it on 2.12, I have not tried on 3.x as there is some migration work we need to do first.

We encountered this at Netflix too, as it turns out. The problem was another dependency on the buildscript classpath that was fatjaring a super old version of Jackson into its jar. The Gradle buildscript classpath nondeterministically picked up this old version of AnnotatedConstructor.

Drop this block into your buildscript classpath block to find the offending jar:

buildscript.configurations.classpath.findAll {
          def file = new java.util.zip.ZipFile(it)
          file.entries().any { it.getName().contains('AnnotatedConstructor') }
}.each { println it }