Description
Describe the bug
When trying to run an integration test the following error occurs:
java.lang.AssertionError: No value at JSON path "$[?(@.name == 'foo' && @.pId == 'bar')]"
at org.springframework.test.util.JsonPathExpectationsHelper.evaluateJsonPath(JsonPathExpectationsHelper.java:295)
...
Caused by: java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReaderI
at com.jayway.jsonpath.internal.DefaultsImpl.<init>(DefaultsImpl.java:17)
...
Caused by: java.lang.ClassNotFoundException: net.minidev.json.writer.JsonReaderI
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
...
This is due to a version clash on transitive dependency net.minidev:json-smart
between spring-security-oauth2-client:5.3.2
and spring-boot-starter-test:2.3.0
.
Here's the partial output from
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:tree -Dverbose=true
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.3.0.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.4.0:test
[INFO] | | +- (net.minidev:json-smart:jar:2.3:test - omitted for conflict with 1.3.1)
=> dependency is net.minidev:json-smart:jar:2.3:test
[INFO] +- org.springframework.security:spring-security-oauth2-client:jar:5.3.2.RELEASE:compile
[INFO] | +- com.nimbusds:oauth2-oidc-sdk:jar:7.1.1:compile
[INFO] | | +- net.minidev:json-smart:jar:1.3.1:compile
=> dependency is net.minidev:json-smart:jar:1.3.1:compile
I'm logging this against Spring Security, as moving from com.nimbusds:oauth2-oidc-sdk:jar:7.1.1
to com.nimbusds:oauth2-oidc-sdk:jar:8.4.2
would likely fix the issue, as that defines its dependency as net.minidev:json-smart:[1.3.1,2.3]
As per maven docs, that would permit for json-smart:2.3
being used:
[1.2,1.3]: Hard requirement for any version between 1.2 and 1.3 inclusive.
By the way: The dependency in oauth2-oidc-sdk:jar:8.4.2
(i.e. [1.3.1,2.3]
) would indicate that json-smart
version 2.3
might be backwards-compatible to version 1.3.1
, but as this is a dependency of a security-related library I would rather not take the chance of just forcing the new version of json-smart
on oauth2-oidc-sdk
using dependencyManagement
.
To Reproduce
Using the following dependencies:
- spring-security-oauth2-client:5.3.2
- spring-boot-starter-test:2.3.0
running this test:
webTestClient.get().uri("${PATH}?pid=bar")
.exchange()
.expectStatus().is2xxSuccessful
.expectBody()
.jsonPath("$[?(@.name == 'foo' && @.pId == 'bar')]").exists()
Expected behavior
Provided the response contains the properties and values specified in the jsonPath, the test should run and pass, not fail due to a missing class.