openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgras...@apache.org
Subject svn commit: r1376799 - /openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java
Date Fri, 24 Aug 2012 00:10:24 GMT
Author: jgrassel
Date: Fri Aug 24 00:10:23 2012
New Revision: 1376799

URL: http://svn.apache.org/viewvc?rev=1376799&view=rev
Log:
OPENJPA-2227: OpenJPA doesn't find custom SequenceGenerators

Modified:
    openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java

Modified: openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java?rev=1376799&r1=1376798&r2=1376799&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java
(original)
+++ openjpa/branches/2.2.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java
Fri Aug 24 00:10:23 2012
@@ -275,10 +275,20 @@ public class SequenceMetaData
             PluginValue plugin = newPluginValue("sequence-plugin");
             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());



Mime
View raw message