openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mprud...@apache.org
Subject svn commit: r446769 - in /incubator/openjpa/trunk/openjpa-kernel/src/main: java/org/apache/openjpa/kernel/BrokerImpl.java resources/org/apache/openjpa/kernel/localizer.properties
Date Fri, 15 Sep 2006 22:12:06 GMT
Author: mprudhom
Date: Fri Sep 15 15:12:05 2006
New Revision: 446769

URL: http://svn.apache.org/viewvc?view=rev&rev=446769
Log:
Add a better error message when casting an instance to PersistenceCapable fails due to the
PersistenceCapable interface being loaded by two separate ClassLoaders

Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?view=diff&rev=446769&r1=446768&r2=446769
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
Fri Sep 15 15:12:05 2006
@@ -4140,6 +4140,18 @@
         if (obj instanceof PersistenceCapable)
             return (PersistenceCapable) obj;
 
+        // check for difference instances of the PersistenceCapable interface
+        // and throw a better error that mentions the class loaders
+        Class[] intfs = obj.getClass().getInterfaces();
+        for (int i = 0; intfs != null && i < intfs.length; i++) {
+            if (intfs[i].getName().equals(PersistenceCapable.class.getName())) {
+                throw new UserException(_loc.get("pc-loader-different",
+                    Exceptions.toString(obj),
+                    PersistenceCapable.class.getClassLoader(),
+                    intfs[i].getClassLoader())).setFailedObject(obj);
+            }
+        }
+
         // not enhanced
         throw new UserException(_loc.get("pc-cast",
             Exceptions.toString(obj))).setFailedObject(obj);

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties?view=diff&rev=446769&r1=446768&r2=446769
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties
Fri Sep 15 15:12:05 2006
@@ -48,6 +48,10 @@
 	marked for rollback only.  The transaction will be rolled back instead.
 refresh-flushed: You cannot refresh an instance that has been flushed to the \
 	data store.
+pc-loader-different: Attempt to cast instance "{0}" to PersistenceCapable failed. \
+    The object implemented org.apache.openjpa.enhance.PersistenceCapable, \
+    but the instance of that interface was loaded by two different ClassLoaders: \
+    "{1}" and "{2}".
 pc-cast: Attempt to cast instance "{0}" to PersistenceCapable failed.  Ensure \
 	that it has been enhanced.
 del-instance: The instance of type "{0}" with oid "{1}" no longer exists in \



Mime
View raw message