Tijs,
Not entirely sure about it, but looking at the code I guess this feature
will only be available with the upcoming 1.3 release of Apache Camel.
Could you give it a try with a 1.3 SNAPSHOT (available on
http://people.apache.org/repo/m2-snapshot-repository/org/apache/camel/apache-camel/1.3-SNAPSHOT/)?
Gert
Tijs wrote:
Hi,
I am using Apache Camel 1.2.0 and I have the following XML configuration:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:ins="http://insurance.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
<camelContext useJmx="true"
xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="file:inbox"/>
<choice>
<when>
<xpath>//ins:insurance-type='Car'</xpath>
<to uri="file:outboxCar"/>
</when>
<otherwise>
<to uri="file:outboxTravel"/>
</otherwise>
</choice>
</route>
</camelContext>
</beans>
I think this XML configuration is correct as it is the same as the XPath
explanation on the Camel website. I however get the following exception:
5-nov-2007 18:03:15 org.apache.camel.processor.Logger log
SEVERE: Invalid xpath: //ins:insurance-type='Car'. Reason:
javax.xml.xpath.XPath
ExpressionException
org.apache.camel.builder.xml.InvalidXPathExpression: Invalid xpath:
//ins:insura
nce-type='Car'. Reason: javax.xml.xpath.XPathExpressionException
at
org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.jav
a:383)
at
org.apache.camel.builder.xml.XPathBuilder.matches(XPathBuilder.java:9
2)
at
org.apache.camel.builder.xml.XPathBuilder.matches(XPathBuilder.java:5
8)
at
org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.ja
va:47)
at
org.apache.camel.processor.DelegateProcessor.processNext(DelegateProc
essor.java:47)
at
org.apache.camel.processor.DelegateProcessor.process(DelegateProcesso
r.java:42)
at
org.apache.camel.management.InstrumentationProcessor.process(Instrume
ntationProcessor.java:33)
at
org.apache.camel.impl.converter.AsyncProcessorTypeConverter$Processor
ToAsynProcessorBridge.process(AsyncProcessorTypeConverter.java:44)
at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChanne
l.java:136)
at
org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChanne
l.java:86)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProc
essor.java:40)
at
org.apache.camel.component.file.FileConsumer.pollFile(FileConsumer.ja
va:131)
at
org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(File
Consumer.java:68)
at
org.apache.camel.component.file.FileConsumer.pollFileOrDirectory(File
Consumer.java:76)
at
org.apache.camel.component.file.FileConsumer.poll(FileConsumer.java:4
9)
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer
.java:63)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:41
7)
at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java
:280)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
access$101(ScheduledThreadPoolExecutor.java:65)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
runPeriodic(ScheduledThreadPoolExecutor.java:142)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.
run(ScheduledThreadPoolExecutor.java:166)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExec
utor.java:650)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:675)
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.xml.xpath.XPathExpressionException
at
com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.ja
va:402)
at
org.apache.camel.builder.xml.XPathBuilder.createXPathExpression(XPath
Builder.java:405)
at
org.apache.camel.builder.xml.XPathBuilder.getExpression(XPathBuilder.
java:269)
at
org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.jav
a:372)
... 24 more
Caused by: javax.xml.transform.TransformerException: Prefix must resolve to
a na
mespace: ins
at
com.sun.org.apache.xpath.internal.compiler.XPathParser.error(XPathPar
ser.java:602)
at
com.sun.org.apache.xpath.internal.compiler.Lexer.mapNSTokens(Lexer.ja
va:638)
at
com.sun.org.apache.xpath.internal.compiler.Lexer.tokenize(Lexer.java:
265)
at
com.sun.org.apache.xpath.internal.compiler.Lexer.tokenize(Lexer.java:
96)
at
com.sun.org.apache.xpath.internal.compiler.XPathParser.initXPath(XPat
hParser.java:108)
at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:162)
at com.sun.org.apache.xpath.internal.XPath.<init>(XPath.java:198)
at
com.sun.org.apache.xpath.internal.jaxp.XPathImpl.compile(XPathImpl.ja
va:394)
... 27 more
Is this a bug or am I doing something wrong here?
Thanks,
Tijs