Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
-
Unknown
Description
json-smart is excluded in camel-jsonpath in favor of using Jackson.
The problem is that json-smart is not truly an optional dependency. Depending on the jsonpath expressions used, you can end up with a ClassNotFoundException.
E.g given this JSON:
{ "messages": [ { "id": 1, "text": "Hello, this is a message from a user." }, { "id": 2, "text": "This is another message from a user." }, { "id": 3, "text": "This message is from a bot.", "bot_id": "123" }, ] }
And then using the expression:
$.messages[?(!@.bot_id)]
You get:
Caused by: java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReaderI at com.jayway.jsonpath.internal.DefaultsImpl.<init>(DefaultsImpl.java:17) at com.jayway.jsonpath.internal.DefaultsImpl.<clinit>(DefaultsImpl.java:15) at com.jayway.jsonpath.Configuration.getEffectiveDefaults(Configuration.java:43) at com.jayway.jsonpath.Configuration.access$000(Configuration.java:29) at com.jayway.jsonpath.Configuration$ConfigurationBuilder.build(Configuration.java:224) at com.jayway.jsonpath.internal.filter.ValueNodes$PathNode.evaluate(ValueNodes.java:679) at com.jayway.jsonpath.internal.filter.RelationalExpressionNode.apply(RelationalExpressionNode.java:37) at com.jayway.jsonpath.internal.filter.FilterCompiler$CompiledFilter.apply(FilterCompiler.java:430) at com.jayway.jsonpath.internal.path.PredicatePathToken.accept(PredicatePathToken.java:77) at com.jayway.jsonpath.internal.path.PredicatePathToken.evaluate(PredicatePathToken.java:60) at com.jayway.jsonpath.internal.path.PathToken.handleObjectProperty(PathToken.java:90) at com.jayway.jsonpath.internal.path.PropertyPathToken.evaluate(PropertyPathToken.java:80) at com.jayway.jsonpath.internal.path.RootPathToken.evaluate(RootPathToken.java:66) at com.jayway.jsonpath.internal.path.CompiledPath.evaluate(CompiledPath.java:99) at com.jayway.jsonpath.internal.path.CompiledPath.evaluate(CompiledPath.java:107) at com.jayway.jsonpath.JsonPath.read(JsonPath.java:191) at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:88) at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:77) at org.apache.camel.jsonpath.JsonPathEngine.readWithInputStream(JsonPathEngine.java:265) at org.apache.camel.jsonpath.JsonPathEngine.doRead(JsonPathEngine.java:219) at org.apache.camel.jsonpath.JsonPathEngine.read(JsonPathEngine.java:124) at org.apache.camel.jsonpath.JsonPathExpression.evaluateJsonPath(JsonPathExpression.java:220) at org.apache.camel.jsonpath.JsonPathExpression.evaluate(JsonPathExpression.java:170) at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:45) at org.apache.camel.processor.TransformProcessor.process(TransformProcessor.java:47) ... 76 more Caused by: java.lang.ClassNotFoundException: net.minidev.json.writer.JsonReaderI at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 101 more
Similar issue reported here when predicates are used:
Attachments
Issue Links
- links to