SpectoLabs / hoverfly-java

Java binding for Hoverfly
Apache License 2.0
168 stars 58 forks source link

Hoverfly 0.14.1 will not run after upgrading to org.springframework.boot 2.5.5 appears to be issue with "com.fasterxml.jackson.dataformat" #264

Closed michaeljamieson10 closed 2 years ago

michaeljamieson10 commented 3 years ago

Description of the bug

Hoverfly will not run after upgrading to org.springframework.boot 2.5.5.

Test suite will only run after excluding the dependency jackson-dataformat-xml from hoverfly, but test with hoverfly will fail.

After upgrading to org.springframework.boot 2.5.5 we receive the following error:

xml

Although the dependency hoverfly was not detected in the above error

excluding jackson-dataformat-xml from hoverfly(image below)

Screen Shot 2021-10-27 at 12 33 45 PM

fixes the issue in the first image and tests ran as intended.

but this excluding of jackson-dataformat-xml from hoverfly will cause hoverfly tests to fail with

Screen Shot 2021-10-27 at 3 16 41 PM

Steps to reproduce the issue

put the following in build.gradle

id "org.springframework.boot" version "2.5.5"

id "io.spring.dependency-management" version "1.0.11.RELEASE"

testImplementation (group: 'io.specto', name: 'hoverfly-java', version: '0.14.1')

Ran with junit 5 junitplatform runner like in following image:

Screen Shot 2021-10-27 at 2 59 29 PM

Observed result

BEFORE excluding the dependency from Hoverfly "com.fasterxml.jackson.dataformat":


An attempt was made to call a method that does not exist. The attempt was made from the following location:

    com.fasterxml.jackson.dataformat.xml.XmlMapper.<init>(XmlMapper.java:176)

The following method did not exist:

    com.fasterxml.jackson.dataformat.xml.XmlMapper.coercionConfigDefaults()Lcom/fasterxml/jackson/databind/cfg/MutableCoercionConfig;

The method's class, com.fasterxml.jackson.dataformat.xml.XmlMapper, is available from the following locations:

    jar:file:/Users/michaeljamieson/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.dataformat/jackson-dataformat-xml/2.12.5/4b872e5a9f7e6644c2dd8d7358ed9fad714d7c90/jackson-dataformat-xml-2.12.5.jar!/com/fasterxml/jackson/dataformat/xml/XmlMapper.class

The class hierarchy was loaded from the following locations:

    com.fasterxml.jackson.dataformat.xml.XmlMapper: file:/Users/michaeljamieson/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.dataformat/jackson-dataformat-xml/2.12.5/4b872e5a9f7e6644c2dd8d7358ed9fad714d7c90/jackson-dataformat-xml-2.12.5.jar
    com.fasterxml.jackson.databind.ObjectMapper: file:/Users/michaeljamieson/.gradle/caches/modules-2/files-2.1/io.github.jav/expo-server-sdk/1.1.0/a49b27d9198999bd4dffa0bf2e27dedd494c79ae/expo-server-sdk-1.1.0.jar
    com.fasterxml.jackson.core.ObjectCodec: file:/Users/michaeljamieson/.gradle/caches/modules-2/files-2.1/io.github.jav/expo-server-sdk/1.1.0/a49b27d9198999bd4dffa0bf2e27dedd494c79ae/expo-server-sdk-1.1.0.jar
    com.fasterxml.jackson.core.TreeCodec: file:/Users/michaeljamieson/.gradle/caches/modules-2/files-2.1/io.github.jav/expo-server-sdk/1.1.0/a49b27d9198999bd4dffa0bf2e27dedd494c79ae/expo-server-sdk-1.1.0.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of com.fasterxml.jackson.dataformat.xml.XmlMapper

Observed result

AFTER excluding the dependency from Hoverfly "com.fasterxml.jackson.dataformat":

id "org.springframework.boot" version "2.5.5"

id "io.spring.dependency-management" version "1.0.11.RELEASE"

testImplementation (group: 'io.specto', name: 'hoverfly-java', version: '0.14.1') {
   exclude group: "com.fasterxml.jackson.dataformat", module: "jackson-dataformat-xml"
}
com/fasterxml/jackson/dataformat/xml/XmlMapper
java.lang.NoClassDefFoundError: com/fasterxml/jackson/dataformat/xml/XmlMapper
    at io.specto.hoverfly.junit.dsl.matchers.HoverflyMatchers.<clinit>(HoverflyMatchers.java:14)
    at io.specto.hoverfly.junit.dsl.StubServiceBuilder.get(StubServiceBuilder.java:46)
    at com.grassp.restservice.api.v1.controller.MetrcOrderIntegration5Test.<init>(MetrcOrderIntegration5Test.java:422)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.junit.platform.commons.util.ReflectionUtils.newInstance(ReflectionUtils.java:513)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:62)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeTestClassConstructor(ClassTestDescriptor.java:345)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateTestClass(ClassTestDescriptor.java:290)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateTestClass(ClassTestDescriptor.java:281)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateAndPostProcessTestInstance(ClassTestDescriptor.java:269)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$testInstancesProvider$2(ClassTestDescriptor.java:259)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$testInstancesProvider$3(ClassTestDescriptor.java:263)
    at java.util.Optional.orElseGet(Optional.java:267)
    at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$testInstancesProvider$4(ClassTestDescriptor.java:262)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:98)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:97)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:111)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:111)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:79)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.util.ArrayList.forEach(ArrayList.java:1257)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:229)
    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:197)
    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:211)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:191)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:137)
    at org.junit.platform.runner.JUnitPlatform.run(JUnitPlatform.java:134)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
    at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:121)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.dataformat.xml.XmlMapper
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 84 more

Expected result

The ability for hoverfly test to run with org.springframework.boot 2.5.5 without excluding dependency.

Additional relevant information

If not indicated above:

  1. Hoverfly Java version: 0.14.1
  2. Anything that might help us to diagnose the problem

When looking at hoverfly dependency using ./gradlew dependencies

Screen Shot 2021-10-27 at 1 26 47 PM
michaeljamieson10 commented 3 years ago

Fixes problem for me, testImplementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.9.0"

testImplementation (group: 'io.specto', name: 'hoverfly-java', version: '0.14.1') { exclude group: "com.fasterxml.jackson.dataformat", module: "jackson-dataformat-xml" }

tommysitu commented 3 years ago

did you mean 2.9.0 works, but not 2.11.4?

michaeljamieson10 commented 3 years ago

Yes 2.9.0 works

tommysitu commented 3 years ago

Can you check this out? https://github.com/tommysitu/springboot-demo I can't reproduce the issue. It's likely that we need to upgrade the jackson library rather than downgrade.