camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Using properties in XPath Spring tags
Date Wed, 05 Oct 2011 15:47:18 GMT
Hi

Thanks for reporting. I have reproduced the issue and created a ticket
https://issues.apache.org/jira/browse/CAMEL-4519

On Tue, Oct 4, 2011 at 8:27 PM, green.sea <casey.lewis.green@gmail.com> wrote:
> Hi,
> I'm trying to inject a property into a <xpath> tag in a Spring camelContext.
>
> According to http://camel.apache.org/xpath.html there exists a function
> "function:properties()" that should pull a property from a configured
> <propertyPlaceholder> configuration file.  This does not seem to work as
> described/expected, but perhaps I'm missing something.  I've tried camel v.
> 2.5, and every release afterwards.
>
> *Dependencies:*
>
>        <dependency>
>            <groupId>org.apache.camel</groupId>
>            <artifactId>camel-core</artifactId>
>            <version>${camel.version}</version>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.camel</groupId>
>            <artifactId>camel-jms</artifactId>
>            <version>${camel.version}</version>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.camel</groupId>
>            <artifactId>camel-mvel</artifactId>
>            <version>${camel.version}</version>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.camel</groupId>
>            <artifactId>camel-quartz</artifactId>
>            <version>${camel.version}</version>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.camel</groupId>
>            <artifactId>camel-spring</artifactId>
>            <version>${camel.version}</version>
>        </dependency>
>        <dependency>
>            <groupId>org.apache.camel</groupId>
>            <artifactId>camel-saxon</artifactId>
>            <version>${camel.version}</version>
>        </dependency>
>
> *Spring Configuration:*
>
> <camelContext id="routes"  xmlns="http://camel.apache.org/schema/spring">
>
>        <propertyPlaceholder id="properties"
> location="classpath:camel/mappings.properties"/>
>
>        <route id="splitter">
>            ...
>
>
>            <split>
>                <xpath>function:properties('split.message.at.xpath')</xpath>
>                <to uri="direct:enrich"/>
>            </split>
>        </route>
>        ...
>        <route id="someRoute">
>            <from uri="direct:enrich"/>
>            ...
>            <setHeader headerName="name">
>                <xpath
> resultType="java.lang.String">function:properties('name.xpath')</xpath>
>            </setHeader>
>            ...
>        </route>
>
>        ...
> </camelContext>
>
>
> *mappings.properties:*
>
> split.message.at.xpath=/Objects/object
> name.xpath=/object/name
>
>
> The exception occurs at the splitter.
> *Exception:*
>
> org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
> function:properties('split.message.at.xpath'). Reason:
> javax.xml.xpath.XPathExpressionException
>        at
> org.apache.camel.builder.xml.XPathBuilder.doInEvaluateAs(XPathBuilder.java:671)
>        at
> org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.java:629)
>        at
> org.apache.camel.builder.xml.XPathBuilder.evaluate(XPathBuilder.java:602)
>        at
> org.apache.camel.builder.xml.XPathBuilder.evaluate(XPathBuilder.java:131)
>        at
> org.apache.camel.processor.Splitter.createProcessorExchangePairs(Splitter.java:99)
>        at
> org.apache.camel.processor.MulticastProcessor.process(MulticastProcessor.java:200)
>        at org.apache.camel.processor.Splitter.process(Splitter.java:94)
>        at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:77)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>        at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:77)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
>        at
> org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:99)
>        at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:77)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.processErrorHandler(RedeliveryErrorHandler.java:299)
>        at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:208)
>        at
> org.apache.camel.processor.DefaultChannel.process(DefaultChannel.java:269)
>        at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:109)
>        at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:77)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.processNext(DelegateAsyncProcessor.java:98)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:89)
>        at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>        at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:103)
>        at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:85)
>        at
> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:92)
>        at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:559)
>        at
> org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:498)
>        at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:467)
>        at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:323)
>        at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:261)
>        at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:977)
>        at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:969)
>        at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:871)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>        at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>        at java.lang.Thread.run(Thread.java:662)
> Caused by: javax.xml.xpath.XPathExpressionException
>        at
> net.sf.saxon.xpath.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:357)
>        at
> org.apache.camel.builder.xml.XPathBuilder.doInEvaluateAs(XPathBuilder.java:657)
>        ... 37 more
> *Caused by: net.sf.saxon.trans.XPathException: Extension function required
> class org.w3c.dom.NodeList; supplied value of class
> net.sf.saxon.value.StringValue could not be converted
>        at
> net.sf.saxon.dom.DOMObjectModel.convertXPathValueToObject(DOMObjectModel.java:395)
>        at net.sf.saxon.dom.DOMObjectModel.access$000(DOMObjectModel.java:42)
>        at net.sf.saxon.dom.DOMObjectModel$5.convert(DOMObjectModel.java:166)
>        at
> net.sf.saxon.xpath.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:352)
>        ... 38 more*
>
>
> Note, this works fine if I hardcode the value instead of sourcing it from a
> property file.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Using-properties-in-XPath-Spring-tags-tp4869840p4869840.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message