Open Joothi opened 4 years ago
This issue is caused by Maven + Springboot causing the wrong version of the Kotlin standard library to be loaded. I recently diagnosed this for someone else. See https://stackoverflow.com/questions/62001663/exception-in-thread-thread-2-java-lang-nosuchmethoderror-kotlin-io-bytestream
Running maven dependency tree plugin showed:
au.com.dius:pact-jvm-consumer-junit5:jar:4.0.10
-> au.com.dius:pact-jvm-consumer:jar:4.0.10
-> io.ktor:ktor-server-netty:jar:1.2.6
-> org.jetbrains.kotlin:kotlin-stdlib:jar:1.2.71
which is the wrong version of the Kotlin standard lib (it should be 1.3.x).
Checking Maven Central, https://search.maven.org/artifact/io.ktor/ktor-server-netty/1.2.6/jar has the following in it's POM:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.3.60</version>
<scope>compile</scope>
</dependency>
Also, https://search.maven.org/artifact/au.com.dius/pact-jvm-core-support/4.0.10/jar has
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>1.3.71</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>1.3.71</version>
<scope>runtime</scope>
</dependency>
Looks like there is the same issue with Gson (#1077).
I was able to fix the provided project by adding the following to the dependencies:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.3.72</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
But I have no idea why Maven is resolving the Kotlin standard library to 1.2.71. Probably time to move to Gradle! :-D
I am seeing the same issue with gradle + groovy
testCompile group: 'au.com.dius.pact.consumer', name: 'groovy', version: '4.1.0'
testCompile group: 'au.com.dius.pact.consumer', name: 'junit', version: '4.1.0'
@Vinodkomeershetty are you using Springboot?
@uglyog We are using groovy on grails for development and also we are using few dependencies related to spring boot
@Vinodkomeershetty the pactPublish
task runs using the build classpath. You may need to include the correct version of Kotlin there. See https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
Getting the Below Errror:
Code:
POM.XML