A little background first. I have an application that is deployed in Weblogic. It receives a Json response from a Service. I'm trying to use JsonPath to navigate the tree and I'm having an unusual issue.
I'm using Maven to build/deploy the application. Dependency:
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>json-path</artifactId>
<version>1.8.1</version>
</dependency>
After getting it running with the full response in Junit and realizing that it wasn't working in the application when deployed, I made it simpler and hard coded a very small subset of the data.
{
"ChangeStatus": {
"Code": {
"value": "1002"
},
"Description": {
"value": "Matched more then 10 records"
}
}
}
Here's what I'm looking at right now...
String miniJson = "{\"ChangeStatus\":{\"Code\":{\"value\":\"1002\"},\"Description\":{\"value\":\"Matched more then 10 records\"}}}";
JsonPath miniJsonPath = new JsonPath(miniJson);
String statusCode = miniJsonPath.getString("ChangeStatus.Code.value");
In JUnit, this code works and I can assert 1002 successfully. In the application after pushing to weblogic, this exact code snippet does not work. It throws a NoSuchMethodError.
Any ideas would be welcome. FYI, we are on Weblogic 10.3.6
Thanks in advance!
What I discovered is that jsonpath depends upon antlr. Weblogic also includes this package, but I believe it is an older version.
I fixed the problem by telling Weblogic to use the classes included in the app. weblogic.xml
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>