List of usage examples for java.util MissingResourceException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:org.apache.openjpa.lib.conf.ProductDerivations.java
/** * Load the given given resource, or return false if it is not a resource * this provider understands. The given class loader may be null. * * @param anchor optional named anchor within a multiple-configuration * resource/*from w w w .j av a 2s. c o m*/ */ public static ConfigurationProvider load(String resource, String anchor, ClassLoader loader) { if (StringUtils.isEmpty(resource)) return null; if (loader == null) loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction()); ConfigurationProvider provider = null; StringBuilder errs = null; // most specific to least Throwable err = null; for (int i = _derivations.length - 1; i >= 0; i--) { try { provider = _derivations[i].load(resource, anchor, loader); if (provider != null) return provider; } catch (Throwable t) { err = t; errs = (errs == null) ? new StringBuilder() : errs.append("\n"); errs.append(_derivations[i].getClass().getName() + ":" + t); } } reportErrors(errs, resource, err); String rsrc = resource + "#" + anchor; MissingResourceException ex = new MissingResourceException(rsrc, ProductDerivations.class.getName(), rsrc); ex.initCause(err); throw ex; }
From source file:org.apache.openjpa.lib.conf.ProductDerivations.java
/** * Load given file, or return false if it is not a file this provider * understands./* w w w. j av a 2s .co m*/ * * @param anchor optional named anchor within a multiple-configuration file */ public static ConfigurationProvider load(File file, String anchor, ClassLoader loader) { if (file == null) return null; if (loader == null) loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction()); ConfigurationProvider provider = null; StringBuilder errs = null; Throwable err = null; // most specific to least for (int i = _derivations.length - 1; i >= 0; i--) { try { provider = _derivations[i].load(file, anchor); if (provider != null) return provider; } catch (Throwable t) { err = t; errs = (errs == null) ? new StringBuilder() : errs.append("\n"); errs.append(_derivations[i].getClass().getName() + ":" + t); } } String aPath = AccessController.doPrivileged(J2DoPrivHelper.getAbsolutePathAction(file)); reportErrors(errs, aPath, err); String rsrc = aPath + "#" + anchor; MissingResourceException ex = new MissingResourceException(rsrc, ProductDerivations.class.getName(), rsrc); ex.initCause(err); throw ex; }
From source file:org.apache.openjpa.lib.conf.ProductDerivations.java
/** * Thrown proper exception for given errors. *///from w w w .j a v a 2 s . c o m private static void reportErrors(StringBuilder errs, String resource, Throwable nested) { if (errs == null) return; MissingResourceException ex = new MissingResourceException(errs.toString(), ProductDerivations.class.getName(), resource); ex.initCause(nested); throw ex; }