Hello,
Has anyone managed to get Saxon working with Tomcat?
I'm sure there should be a "drop jars in WEB-INF/lib
directory" solution, but it doesn't appear to work.
Check out these logs:
JAXP: using thread context class loader (WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@13f136e
) for search
JAXP: Looking up system property
'javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath
/dom'
JAXP: The property is undefined.
JAXP: found null in $java.home/jaxp.properties
JAXP: no META-INF/services/javax.xml.xpath.XPathFactory
file was found
JAXP: attempting to use the platform default W3C DOM
XPath lib
JAXP: instanciating org.apache.xpath.jaxp.XPathFactoryImpl
This comes from trying to create an XPathFactory via
.newInstance(). It appears the services information in
the jars is not being found by the Classloader.
I've tried copying jars to the commons/endorsed
directory, but with no success.
Surely someone else has tried this! There must be an
easy solution...
Thanks,
John
Logged In: YES
user_id=251681
I thought at first this was a duplicate of
https://sourceforge.net/tracker/index.php?func=detail&aid=1553507&group_id=29872&atid=397617,
but although it's related, I don't think that's quite the
case here. Your jaxp.debug output shows that the
META-INF/services/javax.xml.xpath.XPathFactory file, which
should be in saxon8-xpath.jar, wasn't actually found.
I've tried it myself and experienced the same result. I
can't get it to pick the file up from the JAR. To get this
to work, I found I had to explicitly set the Java system
property like this:
System.setProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom",
"net.sf.saxon.xpath.XPathFactoryImpl");
I called this explicitly within the init() method of the
servlet, but it should of course be possible to set the
system property via the init-param elements in the web.xml
configuration file instead.
To be honest, it seems more robust to set this as a
configuration file option rather than letting it depend on
what JAR files happen to be around at run-time. But it would
be nice to know why it doesn't work the way the JAXP
documentation says it should: perhaps it's something to do
with tomcat using a custom classLoader.