List of usage examples for javax.xml.xpath XPathExpressionException getCause
public Throwable getCause()
From source file:org.apache.ode.bpel.rtrep.v2.xpath20.XPath20ExpressionRuntime.java
private Object evaluate(OExpression cexp, EvaluationContext ctx, QName type) throws FaultException { try {/*w w w . j av a 2 s. co m*/ OXPath20ExpressionBPEL20 oxpath20 = ((OXPath20ExpressionBPEL20) cexp); System.setProperty("javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_SAXON, "net.sf.saxon.xpath.XPathFactoryImpl"); // JAXP based XPath 1.0 runtime does not work anymore after a XPath 2.0 has been evaluated if this is set. // System.setProperty("javax.xml.xpath.XPathFactory:"+XPathConstants.DOM_OBJECT_MODEL, // "net.sf.saxon.xpath.XPathFactoryImpl"); System.setProperty("javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_JDOM, "net.sf.saxon.xpath.XPathFactoryImpl"); System.setProperty("javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_XOM, "net.sf.saxon.xpath.XPathFactoryImpl"); System.setProperty("javax.xml.xpath.XPathFactory:" + NamespaceConstant.OBJECT_MODEL_DOM4J, "net.sf.saxon.xpath.XPathFactoryImpl"); XPathFactory xpf = XPathFactory.newInstance(NamespaceConstant.OBJECT_MODEL_SAXON); JaxpFunctionResolver funcResolver = new JaxpFunctionResolver(ctx, oxpath20); JaxpVariableResolver varResolver = new JaxpVariableResolver(ctx, oxpath20, ((XPathFactoryImpl) xpf).getConfiguration()); xpf.setXPathFunctionResolver(funcResolver); xpf.setXPathVariableResolver(varResolver); XPath xpe = xpf.newXPath(); xpe.setNamespaceContext(oxpath20.namespaceCtx); XPathExpression expr = xpe.compile(((OXPath10Expression) cexp).xpath); Node contextNode = ctx.getRootNode() == null ? DOMUtils.newDocument() : ctx.getRootNode(); // Create step nodes in XPath in case it is incompletely instantiated if (oxpath20.insertMissingData) { XPath20ExpressionModifier modifier = new XPath20ExpressionModifier(oxpath20.namespaceCtx, ((XPathFactoryImpl) xpf).getConfiguration().getNamePool()); Node temp = ctx.getRootNode(); if (temp.getLocalName().equals("message") && temp.getNamespaceURI() == null && temp.getFirstChild() != null && temp.getFirstChild().getFirstChild() != null) { modifier.insertMissingData(expr, temp.getFirstChild().getFirstChild()); } else { modifier.insertMissingData(expr, temp); } } Object evalResult = expr.evaluate(contextNode, type); if (evalResult != null && __log.isDebugEnabled()) { __log.debug("Expression " + cexp.toString() + " generated result " + evalResult + " - type=" + evalResult.getClass().getName()); if (ctx.getRootNode() != null) __log.debug("Was using context node " + DOMUtils.domToString(ctx.getRootNode())); } return evalResult; } catch (XPathExpressionException e) { // Extracting the real cause from all this wrapping isn't a simple task Throwable cause = e.getCause() != null ? e.getCause() : e; if (cause instanceof DynamicError) { Throwable th = ((DynamicError) cause).getException(); if (th != null) { cause = th; if (cause.getCause() != null) cause = cause.getCause(); } } throw new FaultException(cexp.getOwner().constants.qnSubLanguageExecutionFault, cause.getMessage(), cause); } catch (WrappedFaultException wre) { __log.debug("Could not evaluate expression because of ", wre); throw (FaultException) wre.getCause(); } catch (Throwable t) { __log.debug("Could not evaluate expression because of ", t); throw new FaultException(cexp.getOwner().constants.qnSubLanguageExecutionFault, t.getMessage(), t); } }