I have problem to use xquery on a JMS message using apache camel and wildfly.
My code reads from an jms queue and try to filter the message
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.cdi.ContextName;
import org.apache.camel.component.jms.JmsComponent;
import org.wildfly.extension.camel.CamelAware;
import javax.annotation.Resource;
import javax.ejb.Startup;
import javax.enterprise.context.ApplicationScoped;
import javax.jms.ConnectionFactory;
@Startup
@CamelAware
@ApplicationScoped
@ContextName("test")
class MyRouteBuilder extends RouteBuilder {
@Resource(mappedName = "java:jboss/DefaultJMSConnectionFactory")
private ConnectionFactory connectionFactory;
@Override
public void configure() throws Exception {
getContext().addComponent("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
from("jms:queue:test1").
routeId("test").
to("log:jms?showAll=true").
filter().xquery("fn:contains(//person/name/text(),'james')").
to("file://Users/asse/Outbound");
When I run the code with the message
<person><name>james</name><person>
I get the error:
Message History --------------------------------------------------------------------------------------------------------------------------------------- RouteId ProcessorId Processor
Elapsed (ms) [test ] [test ] [jms://queue:test1
] [ 5] [test ] [to7 ] [log:jms?showAll=true
] [ 1] [test ] [filter7 ] [filter[xquery{XQuery[net.sf.saxon.query.XQueryExpression@3af367ad]}] ] [ 2]Stacktrace ---------------------------------------------------------------------------------------------------------------------------------------: org.apache.camel.RuntimeExpressionException: java.lang.NullPointerException: External object cannot wrap a Java null at org.apache.camel.component.xquery.XQueryBuilder.matches(XQueryBuilder.java:220) at org.apache.camel.processor.FilterProcessor.matches(FilterProcessor.java:65) at org.apache.camel.processor.FilterProcessor.process(FilterProcessor.java:51) at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77) at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542) at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
I don't understand why! Can anyone help me with this problem??