[
https://issues.apache.org/jira/browse/SMX4-1375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13930344#comment-13930344
]
metatech commented on SMX4-1375:
--------------------------------
To use XPATH 2 expressions in Camel routes running in ServiceMix 4.5.3, I did
the following steps :
1. In the Karaf console, install and start the Saxon bundle :
install -s
mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.saxon/9.4.0.1_2
2. Edit the $SERVICEMIX_HOME/bin/karaf shell script, and add the following
option in $JAVA_OPTS
-Djavax.xml.xpath.XPathFactory:http://saxon.sf.net/jaxp/xpath/om=net.sf.saxon.xpath.XPathFactoryImpl
3. In my application bundle, add the following OSGi import in the pom.xml
manifest section :
net.sf.saxon.xpath
This solution works, although I think it is not in line with the OSGi spirit :
first a global system property must be defined, secondly the application bundle
must import a transitive dependency of Camel.
I tried other solutions, which all failed at some point :
- adding the JAXP specs bundle : problems with the XML parsing of Blueprint and
Pax Web, as well as dependency chains conflicts
- adding META-INF/services in the Saxon JAR
- adding saxon in the "endorsed" directory (with META-INF/services)
- adding a JAR in the "endorsed" directory with only META-INF/services (not
classes)
- adding the system property in "etc/system.properties"
For reference, here is the detailed stack trace I had before applying the
solution.
{code}
Caused by: org.apache.camel.RuntimeExpressionException: Error starting
XPathBuilder
at
org.apache.camel.builder.xml.XPathBuilder.createXPathExpression(XPathBuilder.java:896)[121:org.apache.camel.camel-core:2.10.7]
at
org.apache.camel.builder.xml.XPathBuilder.evaluateAs(XPathBuilder.java:743)[121:org.apache.camel.camel-core:2.10.7]
... 81 more
Caused by: javax.xml.xpath.XPathFactoryConfigurationException: No XPathFctory
implementation found for the object model: http://saxon.sf.net/jaxp/xpath/om
at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:152)[:]
at
org.apache.camel.builder.xml.XPathBuilder.initDefaultXPathFactory(XPathBuilder.java:1157)[121:org.apache.camel.camel-core:2.10.7]
at
org.apache.camel.builder.xml.XPathBuilder.createXPathFactory(XPathBuilder.java:1137)[121:org.apache.camel.camel-core:2.10.7]
at
org.apache.camel.builder.xml.XPathBuilder.doStart(XPathBuilder.java:1093)[121:org.apache.camel.camel-core:2.10.7]
at
org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)[121:org.apache.camel.camel-core:2.10.7]
at
org.apache.camel.builder.xml.XPathBuilder.createXPathExpression(XPathBuilder.java:894)[121:org.apache.camel.camel-core:2.10.7]
... 82 more
{code}
> Unable to use Saxon implementation for camel xpath
> --------------------------------------------------
>
> Key: SMX4-1375
> URL: https://issues.apache.org/jira/browse/SMX4-1375
> Project: ServiceMix 4
> Issue Type: Bug
> Components: Bundles
> Affects Versions: 4.5.0
> Environment: Windows 7
> Reporter: David Daum
> Fix For: 4.6.0
>
>
> features:install servicemix-saxon ...yields error...
> Error executing command: URL
> [mvn:org.apache.servicemix.naming/org.apache.servicemix.naming/1.6.0] could
> not be resolved.
> ------------------------
> when using <xpath saxon="true" in camel route, the following error is seen:
> No XPathFctory implementation found for the object model:
> http://saxon.sf.net/jaxp/xpath/om
--
This message was sent by Atlassian JIRA
(v6.2#6252)