XPath node exception: JAXP implementation or earlier: class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl

Hi,

I yet again seem to find myself in ‘xerces hell’. We’re seeing the error when tyring to run the XPath node. I’m pretty sure the bundle is loading an unexpected version of xerces.

java.lang.ExceptionInInitializerError
	at org.knime.core.data.xml.io.XMLCellReaderFactory.createXMLCellReader(XMLCellReaderFactory.java:90)
	at org.knime.core.data.xml.XMLCellContent.parse(XMLCellContent.java:262)
	at org.knime.core.data.xml.XMLCellContent.getDocument(XMLCellContent.java:220)
	at org.knime.core.data.xml.XMLCellContent.getDocumentSupplier(XMLCellContent.java:306)
	at org.knime.core.data.xml.XMLBlobCell.getDocumentSupplier(XMLBlobCell.java:193)
	at org.knime.xml.node.xpath2.CellFactories.XPathCollectionCellFactory.evaluateNodeSet(XPathCollectionCellFactory.java:429)
	at org.knime.xml.node.xpath2.CellFactories.XPathCollectionCellFactory.getCell(XPathCollectionCellFactory.java:205)
	at org.knime.xml.node.xpath2.CellFactories.XPathCollectionCellFactory.getCells(XPathCollectionCellFactory.java:183)
	at org.knime.core.data.container.RearrangeColumnsTable.calcNewCellsForRow(RearrangeColumnsTable.java:505)
	at org.knime.core.data.container.ColumnRearrangerFunction.compute(ColumnRearrangerFunction.java:121)
	at org.knime.xml.node.xpath2.XPathNodeModel.executeQueriesAndUngroupToRowsOnTheFly(XPathNodeModel.java:252)
	at org.knime.xml.node.xpath2.XPathNodeModel.executeInternal(XPathNodeModel.java:208)
	at org.knime.xml.node.xpath2.XPathNodeModel.execute(XPathNodeModel.java:188)
	at org.knime.core.node.NodeModel.execute(NodeModel.java:733)
	at org.knime.core.node.NodeModel.executeModel(NodeModel.java:567)
	at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1186)
	at org.knime.core.node.Node.execute(Node.java:973)
	at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:559)
	at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:95)
	at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:179)
	at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:110)
	at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:328)
	at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:204)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
	at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)
Caused by: java.lang.UnsupportedOperationException:  setXIncludeAware is not supported on this JAXP implementation or earlier: class org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
	at javax.xml.parsers.DocumentBuilderFactory.setXIncludeAware(DocumentBuilderFactory.java:584)
	at org.knime.core.data.xml.io.XMLDOMCellReader.<clinit>(XMLDOMCellReader.java:103)
	... 27 more

Do anyone have any tips for how I can prevent this? I suspect one our our internal bundles may be providing another copy of xerces and this isn’t being separated as desired in the OSGi environment.

All tips welcome.

Cheers

Sam

Hi @swebb,
I hope I can guide you out of hell then :smiling_imp: ,You could try debugging and setting a breakpoint at the UnsupportedOperationException to see where the other xerces bundle is located. You can experiment with the dependency order in the Required Plug-ins tab in the plugin.xml editor, I have found in the past that you can fix some of these issues by putting the core KNIME dependencies higher than your own external bundles.

best,
Gabriel

Hi @gab1one

Thanks for the tips!

Unfortunately it’s a core KNIME plugin that has the issue not one of mine, but I think it’s because I or someone else introduced another version of xerces.

It only materialises when installed in a normal KNIME instance and not int he development environment also making it trickier to find out.

I do appear to have got it to go away for the time being, I searching for any reference to xerces in by code base and found a plugin had an embedded jar for xerces 2.5. Replacing this with an OSGi dependency on 2.7 (or 2.9?) seems to have worked.

Cheers

Sam

Hi @sweb,
I am glad it worked :slight_smile:

Embedded jars can cause problems like this, using an OSGi dependency wherever possible is the best way to avoid issues like this.
best,
Gabriel