question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NoSuchMethodError on PactDslJsonBody.booleanType

See original GitHub issue

If booleanType is called in object in array, NoSuchMethodError is thrown. I got this error with “au.com.dius.pact.consumer:java8:4.1.17” and “au.com.dius.pact.consumer:junit5:4.2.0”.

This test code below can reproduce the error.

@ExtendWith(PactConsumerTestExt::class)
internal class BooleanTypeFailingTest {

    @Pact(provider = "serviceA", consumer = "serviceB")
    fun pact(builder: PactDslWithProvider): RequestResponsePact {
        return builder
            .given("foo")
            .uponReceiving("bar")
            .path("/v1/test")
            .method("POST")
            .body(
                LambdaDsl.newJsonBody {
                    it.array("array") { array ->
                        array.`object` { obj ->
                            obj.booleanType("boolean1", true)
                        }
                    }
                }.build()
            )
            .willRespondWith()
            .status(200)
            .toPact()
    }

    @Test
    @PactTestFor(providerName = "serviceA", port = "0", pactMethod = "pact")
    fun configDomain(mockServer: MockServer) {
    }
}

stacktrace:

'au.com.dius.pact.consumer.dsl.PactDslJsonBody au.com.dius.pact.consumer.dsl.PactDslJsonBody.booleanType(java.lang.String, java.lang.Boolean)'
java.lang.NoSuchMethodError: 'au.com.dius.pact.consumer.dsl.PactDslJsonBody au.com.dius.pact.consumer.dsl.PactDslJsonBody.booleanType(java.lang.String, java.lang.Boolean)'
	at io.pactfoundation.consumer.dsl.LambdaDslObject.booleanType(LambdaDslObject.java:178)
	at BooleanTypeFailingTest$pact$1$1$1.accept(BooleanTypeFailingTest.kt:25)
	at BooleanTypeFailingTest$pact$1$1$1.accept(BooleanTypeFailingTest.kt:12)
	at io.pactfoundation.consumer.dsl.LambdaDslJsonArray.object(LambdaDslJsonArray.java:35)
	at BooleanTypeFailingTest$pact$1$1.accept(BooleanTypeFailingTest.kt:24)
	at BooleanTypeFailingTest$pact$1$1.accept(BooleanTypeFailingTest.kt:12)
	at io.pactfoundation.consumer.dsl.LambdaDslObject.array(LambdaDslObject.java:588)
	at BooleanTypeFailingTest$pact$1.accept(BooleanTypeFailingTest.kt:23)
	at BooleanTypeFailingTest$pact$1.accept(BooleanTypeFailingTest.kt:12)
	at io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody(LambdaDsl.java:75)
	at BooleanTypeFailingTest.pact(BooleanTypeFailingTest.kt:22)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
	at org.junit.platform.commons.support.ReflectionSupport.invokeMethod(ReflectionSupport.java:198)
	at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.lookupPact(PactConsumerTestExt.kt:345)
	at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.setupMockServer(PactConsumerTestExt.kt:245)
	at au.com.dius.pact.consumer.junit5.PactConsumerTestExt.beforeTestExecution(PactConsumerTestExt.kt:233)
...snip

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
uglyogcommented, Mar 6, 2021

Ah! au.com.dius.pact.consumer:java8 has been merged into au.com.dius.pact:consumer:4.2.0, just remove that dependency.

0reactions
nagkumarcommented, Oct 5, 2022

When moving from testImplementation 'au.com.dius.pact.consumer:junit5:4.1.39' to testImplementation 'au.com.dius.pact.consumer:junit5:4.2.0' the dependency of testImplementation 'au.com.dius.pact.consumer:junit5:4.1.39 of testImplementation 'au.com.dius.pact.consumer:java8:4.1.39 can be removed by changing the imports

e.g these imports in the code

import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonArrayMinLike;
import static io.pactfoundation.consumer.dsl.LambdaDsl.newJsonBody;

can be changed to

import static au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonArrayMinLike;
import static au.com.dius.pact.consumer.dsl.LambdaDsl.newJsonBody;
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use PactDslJsonBody in au.com.dius.pact.consumer.dsl
<init>. Constructs a new body as a child as a copy of an existing one · stringType. Attributes that can be any string...
Read more >
NoSuchMethodException when using SpringRestPactRunner
I am using SpringRestPactRunner for the pact provider test. In the build.gradlew, I have put testImplementation 'au.com.dius:pact-jvm-provider- ...
Read more >
Provides a DSL for use with Java to build consumer pacts.
Building JSON bodies with PactDslJsonBody DSL​ ... booleanType, Will match all boolean values (true and false).
Read more >
PactDslJsonBody (pact-jvm-consumer-junit_2.11 2.2.0 API)
PactDslJsonBody · arrayLike(java.lang.String name). Array field where each element must match the following object. PactDslJsonBody · booleanType(java.lang.
Read more >
How to Fix java.lang.NoSuchMethodError in Java - Rollbar
A java.lang.NoSuchMethodError is a runtime error which occurs when a method is called that exists at compile time, but does not exist at ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found