List of usage examples for javax.servlet.jsp.el ELException getRootCause
public Throwable getRootCause()
From source file:com.streamsets.datacollector.el.ELEvaluator.java
@Override @SuppressWarnings("unchecked") public <T> T evaluate(final ELVars vars, String expression, Class<T> returnType) throws ELEvalException { VariableResolver variableResolver = new VariableResolver() { @Override//from w w w . j av a 2 s. com public Object resolveVariable(String name) throws ELException { Object value = constants.get(name); if (!vars.hasVariable(name)) { if (value == null && !constants.containsKey(name)) { throw new ELException(Utils.format("Constants/Variable '{}' cannot be resolved", name)); } } else { value = vars.getVariable(name); } return value; } }; try { return (T) EVALUATOR.evaluate(expression, returnType, variableResolver, functionMapper); } catch (ELException e) { LOG.debug("Error valuating EL '{}': {}", expression, e.toString(), e); Throwable t = e; if (e.getRootCause() != null) { t = e.getRootCause(); } throw new ELEvalException(CommonError.CMN_0104, expression, t.toString(), e); } }
From source file:org.apache.oozie.util.ELEvaluator.java
/** * Evaluate an EL expression. <p>//ww w . j a va2s . c o m * * @param expr EL expression to evaluate. * @param clazz return type of the EL expression. * @return the object the EL expression evaluated to. * @throws Exception thrown if an EL function failed due to a transient error or EL expression could not be * evaluated. */ @SuppressWarnings({ "unchecked", "deprecation" }) public <T> T evaluate(String expr, Class<T> clazz) throws Exception { ELEvaluator existing = current.get(); try { current.set(this); return (T) evaluator.evaluate(expr, clazz, context, context); } catch (ELException ex) { if (ex.getRootCause() instanceof Exception) { throw (Exception) ex.getRootCause(); } else { throw ex; } } finally { current.set(existing); } }
From source file:org.apache.oozie.util.ELEvaluator.java
/** * Check if the input expression contains sequence statically. for example * identify if "," is present outside of a function invocation in the given * expression. Ex "${func('abc')},${func('def'}", * * @param expr - Expression string// www .java2 s . co m * @param sequence - char sequence to check in the input expression * @return true if present * @throws Exception Exception thrown if an EL function failed due to a * transient error or EL expression could not be parsed */ public boolean checkForExistence(String expr, String sequence) throws Exception { try { Object exprString = evaluator.parseExpressionString(expr); if (exprString instanceof ExpressionString) { for (Object element : ((ExpressionString) exprString).getElements()) { if (element instanceof String && element.toString().contains(sequence)) { return true; } } } else if (exprString instanceof String) { if (((String) exprString).contains(sequence)) { return true; } } return false; } catch (ELException ex) { if (ex.getRootCause() instanceof Exception) { throw (Exception) ex.getRootCause(); } else { throw ex; } } }