Search code examples
activemq-classicjsonpath

No language could be found for jsonpath


I'm trying to aggregate messages using jsonpath in activemq. But when I try to start the activemq, I get such exception:

ERROR: org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRo
uteException: Failed to create route route2 at: >>> Choice[[When[jsonpath{$.pers
on[?(@.position = 'manager')]} -> [To[activemq:queue:test.manager]]]] Otherwise[
[To[activemq:queue:test.nonManager]]]] <<< in route: Route(route2)[[From[activem
q:queue:test.other]] -> [Choice[[... because of No language could be found for:
jsonpath

My Route looks like this:

from("activemq:queue:test.other")
                .choice()
                .when().jsonpath("$.person[?(@.position = 'manager')]")
                .to("activemq:queue:test.manager")
                .otherwise()
                .to("activemq:queue:test.nonManager")
                .end();

Solution

  • The camel version bundled with ActiveMQ is limited to do basic routing to and from queues.

    You can extend the dependencies in your lib/camel with features you want. Start out with the top level jar and grab all dependencies from Maven. I.e. camel--.jar In your case, if you are using activemq 5.11.0, it will be camel-jsonpath-2.14.1.jar

    I typically use a script like this (using Apache Ivy to download the dependency graph) in the apache-activemq-5.11.0/lib/camel folder. Adjust script if you need to use Windows or similar.

    curl -L -O http://search.maven.org/remotecontent\?filepath\=org/apache/ivy/ivy/2.3.0/ivy-2.3.0.jar
    java -jar ivy-2.3.0.jar -dependency org.apache.camel camel-jsonpath 2.14.1 -retrieve "lib/[artifact]-[revision](-[classifier]).[ext]"
    rm slf4j-api-1.6.6.jar
    rm ivy-2.3.0.jar     
    

    Note the cleanup in the end. Remove all dependencies that might cause a conflict with other dependencies already found in ActiveMQ's lib folder.