From 5c05a69ce6f371616dfb049fc1c996260b10a394 Mon Sep 17 00:00:00 2001 From: Jody Grassel Date: Mon, 30 Jul 2012 15:40:35 +0000 Subject: [PATCH] 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 --- .../org/apache/openjpa/meta/SequenceMetaData.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java index a8a26f56d..5834da4c4 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java @@ -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());