You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by mp...@apache.org on 2007/11/29 02:17:50 UTC
svn commit: r599239 -
/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
Author: mprudhom
Date: Wed Nov 28 17:17:47 2007
New Revision: 599239
URL: http://svn.apache.org/viewvc?rev=599239&view=rev
Log:
Added nested stack trace to the MissingResourceException as an additional diagnostic for issues around ProductDerivations.
Modified:
openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java?rev=599239&r1=599238&r2=599239&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java Wed Nov 28 17:17:47 2007
@@ -32,6 +32,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.openjpa.lib.util.J2DoPrivHelper;
+import org.apache.openjpa.lib.util.JavaVersions;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.lib.util.Services;
@@ -254,19 +255,22 @@
ConfigurationProvider provider = null;
StringBuffer 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 StringBuffer() : errs.append("\n");
errs.append(_derivations[i].getClass().getName() + ":" + t);
}
}
- reportErrors(errs, resource);
- throw new MissingResourceException(resource,
- ProductDerivations.class.getName(), resource);
+ reportErrors(errs, resource, err);
+ throw (MissingResourceException) JavaVersions.initCause
+ (new MissingResourceException(resource,
+ ProductDerivations.class.getName(), resource), err);
}
/**
@@ -284,6 +288,7 @@
J2DoPrivHelper.getContextClassLoaderAction());
ConfigurationProvider provider = null;
StringBuffer errs = null;
+ Throwable err = null;
// most specific to least
for (int i = _derivations.length - 1; i >= 0; i--) {
try {
@@ -291,15 +296,17 @@
if (provider != null)
return provider;
} catch (Throwable t) {
+ err = t;
errs = (errs == null) ? new StringBuffer() : errs.append("\n");
errs.append(_derivations[i].getClass().getName() + ":" + t);
}
}
String aPath = (String) AccessController.doPrivileged(
J2DoPrivHelper.getAbsolutePathAction(file));
- reportErrors(errs, aPath);
- throw new MissingResourceException(aPath,
- ProductDerivations.class.getName(), aPath);
+ reportErrors(errs, aPath, err);
+ throw (MissingResourceException) JavaVersions.initCause
+ (new MissingResourceException(aPath,
+ ProductDerivations.class.getName(), aPath), err);
}
/**
@@ -328,6 +335,7 @@
ConfigurationProvider provider = null;
StringBuffer errs = null;
String type = (globals) ? "globals" : "defaults";
+ Throwable err = null;
// most specific to least
for (int i = _derivations.length - 1; i >= 0; i--) {
try {
@@ -336,22 +344,25 @@
if (provider != null)
return provider;
} catch (Throwable t) {
+ err = t;
errs = (errs == null) ? new StringBuffer() : errs.append("\n");
errs.append(_derivations[i].getClass().getName() + ":" + t);
}
}
- reportErrors(errs, type);
+ reportErrors(errs, type, err);
return null;
}
/**
* Thrown proper exception for given errors.
*/
- private static void reportErrors(StringBuffer errs, String resource) {
+ private static void reportErrors(StringBuffer errs, String resource,
+ Throwable nested) {
if (errs == null)
return;
- throw new MissingResourceException(errs.toString(),
- ProductDerivations.class.getName(), resource);
+ throw (MissingResourceException) JavaVersions.initCause
+ (new MissingResourceException(errs.toString(),
+ ProductDerivations.class.getName(), resource), nested);
}
/**
@@ -367,6 +378,7 @@
final String propertiesLocation) {
List fqAnchors = new ArrayList();
StringBuffer errs = null;
+ Throwable err = null;
for (int i = _derivations.length - 1; i >= 0; i--) {
try {
if (propertiesLocation == null) {
@@ -395,11 +407,12 @@
}
}
} catch (Throwable t) {
+ err = t;
errs = (errs == null) ? new StringBuffer() : errs.append("\n");
errs.append(_derivations[i].getClass().getName() + ":" + t);
}
}
- reportErrors(errs, propertiesLocation);
+ reportErrors(errs, propertiesLocation, err);
return fqAnchors;
}