Ran into the same problem a while back. My fix was to help the JBoss ClassLoader "pick one" at runtime, by doing an import like:import javax.xml.xpath.*;instead of specifically importing XPathConstants and other classes in that package.
import javax.xml.xpath.*;// ...DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();org.w3c.Document doc = dbf.newDocumentBuilder().parse(inputstream);XPath xp = XPathFactory.newInstance().newXPath();XPathExpression exp = xp.compile("/my/xpath/query");(NodeList) res = (NodeList) exp.evaluate(doc, XPathConstants.NODESET);// ...
To be honest, I was surprised when that had worked for me. It was at the long end of trying all sorts of things including pulling my hair out, but the code also worked on another server afterwards so I thought that had been it.I'm not doing anything special really.. import javax.xml.xpath.*;// ...DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();org.w3c.Document doc = dbf.newDocumentBuilder().parse(inputstream);XPath xp = XPathFactory.newInstance().newXPath();XPathExpression exp = xp.compile("/my/xpath/query");(NodeList) res = (NodeList) exp.evaluate(doc, XPathConstants.NODESET);// ...