When the “javax.xml.xpath.XpathFactory” class is used, the Code may behave differently in Java Code activity from running outside BW.
book
Article ID: KB0088156
calendar_today
Updated On:
Products
Versions
TIBCO ActiveMatrix BusinessWorks
-
Not Applicable
-
Description
Resolution: Description: ============ With javax.xml.xpath.XpathFactory imported, we create an XpathFactory instance like this: ******************************* XPathFactory xpFactory = XPathFactory.newInstance(); ******************************* Then we use this instance in subsequent operations (parsing XML document) but find it behaves differently in BW Java Code from running outside BW (say, in Eclipse). This problem can only be seen in BW 5.7.1 or higher.
Environment: =========== Tibco TRA: 5.6.1 Tibco BW: 5.7.1 or higher
Symptoms: ======== Some operations such as XPath Evaluation will return different results.
Cause: ===== The issue is caused by that net.sf.saxon.xpath.XPathFactoryImpl becomes the default XPath Factory since BW 5.7.1.
Resolution: ========== To resolve it, we can set the XPath Factory back to the original one: ******************************* String DEFAULT_OBJECT_MODEL = "http://java.sun.com/jaxp/xpath/dom"; System.setProperty( "javax.xml.xpath.XPathFactory:" + DEFAULT_OBJECT_MODEL, "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl"); ... XPathFactory xpFactory = XPathFactory.newInstance(DEFAULT_OBJECT_MODEL); ******************************* Then it should behave the same as outside BW.
Issue/Introduction
When the “javax.xml.xpath.XpathFactory” class is used, the Code may behave differently in Java Code activity from running outside BW.