Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got the NoSuchMethodError for CollectionsKt.maxWithOrNull #1751

Closed
pax-prospection opened this issue Dec 19, 2023 · 2 comments
Closed

Got the NoSuchMethodError for CollectionsKt.maxWithOrNull #1751

pax-prospection opened this issue Dec 19, 2023 · 2 comments

Comments

@pax-prospection
Copy link

I got the Kotlin error when tried to verify the PACT DSL response

java.lang.NoSuchMethodError: 'java.lang.Object kotlin.collections.CollectionsKt.maxWithOrNull(java.lang.Iterable, java.util.Comparator)'
	at au.com.dius.pact.core.matchers.MatchingContext.selectBestMatcher(Matching.kt:55)
	at au.com.dius.pact.core.matchers.MatchingContext.selectBestMatcher$default(Matching.kt:46)
	at au.com.dius.pact.core.matchers.JsonContentMatcher.compareLists(JsonContentMatcher.kt:106)
	at au.com.dius.pact.core.matchers.JsonContentMatcher.compare(JsonContentMatcher.kt:82)
	at au.com.dius.pact.core.matchers.JsonContentMatcher.compareMaps(JsonContentMatcher.kt:159)
	at au.com.dius.pact.core.matchers.JsonContentMatcher.compare(JsonContentMatcher.kt:80)
	at au.com.dius.pact.core.matchers.JsonContentMatcher.matchBody(JsonContentMatcher.kt:36)
	at au.com.dius.pact.core.matchers.Matching.matchBody(Matching.kt:235)
	at au.com.dius.pact.core.matchers.ResponseMatching.responseMismatches(ResponseMatching.kt:35)
	at au.com.dius.pact.provider.ResponseComparison$Companion.compareResponse(ResponseComparison.kt:214)
	at au.com.dius.pact.provider.ProviderVerifier.verifyRequestResponsePact(ProviderVerifier.kt:1032)
	at au.com.dius.pact.provider.junit5.PactVerificationContext.validateTestExecution(PactVerificationContext.kt:110)
	at au.com.dius.pact.provider.junit5.PactVerificationContext.verifyInteraction(PactVerificationContext.kt:61)
	

I already tried to install the kotlin version 1.8.20 in gradle but still not helpful:

id "org.jetbrains.kotlin.jvm" version "1.8.20"

Currently, I'm using the latest version for pact provider:

    testImplementation 'au.com.dius.pact.provider:junit5spring:4.5.8'
@rholshausen
Copy link
Contributor

That method has been available in Kotlin since 1.4, so there must be something wrong with your project. Are you using Kotlin as well?

It's not the Kotlin plugin that is needed, but the Kotlin standard library. Try adding org.jetbrains.kotlin:kotlin-stdlib:1.7.22 or maybe try Pact-JVM 4.6.4 instead.

@pax-prospection
Copy link
Author

pax-prospection commented Dec 21, 2023

I found that the issue come from the lib de.adesso:junit-insights:1.1.0: It's using the old kotlin library. Although overriding the kotlin to org.jetbrains.kotlin:kotlin-stdlib:1.7.22 but it's still not work. We're using JAVA 11 so, we upgrade kotlin to 7.22 . There are 2 solutions:

  1. Just remove junit-insights it's not used
  2. excluded all kotlin dependencies from the lib junit-insights in your gradle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants