OPENJPA-2227: OpenJPA doesn't find custom SequenceGenerators

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1367126 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jody Grassel 2012-07-30 15:40:35 +00:00
parent 423d1d18e4
commit 5c05a69ce6
1 changed files with 12 additions and 3 deletions

View File

@ -276,9 +276,18 @@ public class SequenceMetaData
plugin.setString(_plugin);
String clsName = plugin.getClassName();
Class cls = Class.forName(clsName, true,
AccessController.doPrivileged(
J2DoPrivHelper.getClassLoaderAction(Seq.class)));
Class cls = null;
try {
cls = Class.forName(clsName, true,
AccessController.doPrivileged(J2DoPrivHelper.getClassLoaderAction(Seq.class)));
} catch (ClassNotFoundException cnfe) {
// Target sequence type is loaded by the ClassLoader responsible for OpenJPA classes.
// This can happen if the custom sequence implementation is a class that belongs to
// a child ClassLoader - a situation that can easily happen in a JEE environment.
// Fall back to the envLoader to try load the class.
cls = Class.forName(clsName, true, envLoader);
}
StringBuilder props = new StringBuilder();
if (plugin.getProperties() != null)
props.append(plugin.getProperties());