java.lang.NoSuchMethodError for latest java8 junit5 when using both consumer and provider in project
See original GitHub issueExpected behavior -> When running junit5 using the latest Pact version for java 8 in IDE, be able to run the consumer and provider tests (separate run for each) as well as on the command line (using mvn and only including the requisite test classes).
Actual behavior -> Running the test using the IDE or mvn produces the following error:
[ERROR] test_full_consumer_for_event{List} Time elapsed: 0.033 s <<< ERROR!
java.lang.NoSuchMethodError: au.com.dius.pact.core.support.expressions.ExpressionParser.parseExpression$default(Ljava/lang/String;Lau/com/dius/pact/core/support/expressions/DataType;Lau/com/dius/pact/core/support/expressions/ValueResolver;ZILjava/lang/Object;)Ljava/lang/Object;
When I exclude the dependency au.com.dius.pact.core:support
then I am able to run the consumer test (but, obviously not the provider tests)
Versions used:
<dependency>
<groupId>au.com.dius.pact.consumer</groupId>
<artifactId>junit5</artifactId>
<version>4.1.28</version>
<scope>test</scope>
</dependency>
<dependency><!-- Added to allow for the LambdaDsl configuration -->
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-consumer-java8</artifactId>
<version>4.0.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>au.com.dius.pact.provider</groupId>
<artifactId>junit5</artifactId>
<version>4.1.28</version>
<scope>test</scope>
</dependency>
Looking at the code changes, it appears the class and method that’s missing the expected argument is in the ExpressionParser.kt.
Link to the change: https://github.com/pact-foundation/pact-jvm/commit/d3f49648c064ace5e95334ffe6faa6088ec812e9#diff-60f5a5b831e279e4b778ce72ce319289d154ab60ec3535191a0737371c817c8d
Please let me know how to be able to run both consumer and provider tests (I’m doing Async validation if that helps) in the same project.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Thanks so much for a quick response.
If I do that, is there another place where I can get the ability to use the Lambda Dsl which is indeed much easier to manage/read?
I’m referring to this: https://docs.pact.io/implementation_guides/jvm/consumer#a-lambda-dsl-for-pact
The solution was simple, the needed dependencies list that worked is: (turns out the dependency artifact and group being off was the culprit) 😃