pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.08k stars 479 forks source link

Spring Boot Provider test broken after spring boot 2.1 upgrade #805

Closed tinexw closed 5 years ago

tinexw commented 5 years ago

Hi,

I can no longer run Spring provider tests after upgrading Spring Boot from 2.0.6 to 2.1.0:

kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath

    at kotlin.jvm.internal.ClassReference.error(ClassReference.kt:75)
    at kotlin.jvm.internal.ClassReference.getAnnotations(ClassReference.kt:27)
    at au.com.dius.pact.provider.junit.PactRunner.getPactSource(PactRunner.kt:192)
    at au.com.dius.pact.provider.spring.SpringRestPactRunner.getPactSource(SpringRestPactRunner.kt:58)
    at au.com.dius.pact.provider.junit.PactRunner.<init>(PactRunner.kt:78)
    at au.com.dius.pact.provider.junit.RestPactRunner.<init>(RestPactRunner.kt:8)
    at au.com.dius.pact.provider.spring.SpringRestPactRunner.<init>(SpringRestPactRunner.kt:23)
    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:408)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

kotlin was upgraded from 1.2.51 to 1.2.71 by the spring boot upgrade (s. https://github.com/spring-projects/spring-boot/issues/14766). A workaround is to override the kotlin version provided by spring boot with the old version

<properties>
    <kotlin.version>1.2.51</kotlin.version>
</properties>

However, it would be good if it would work out-of-the box again.

I'm using pact-jvm-provider-spring_2.12, most recent version (3.5.24).

uglyog commented 5 years ago

I'll upgrade the Kotlin version. In the mean time, you can use 3.6.0 which is built against 1.2.71.