geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r345580 - /geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/ResourceReference.java
Date Fri, 18 Nov 2005 21:32:57 GMT
Author: djencks
Date: Fri Nov 18 13:32:55 2005
New Revision: 345580

URL: http://svn.apache.org/viewcvs?rev=345580&view=rev
Log:
Provide more information when a resource reference does not implement the asserted interface

Modified:
    geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/ResourceReference.java

Modified: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/ResourceReference.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/ResourceReference.java?rev=345580&r1=345579&r2=345580&view=diff
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/ResourceReference.java
(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/ResourceReference.java
Fri Nov 18 13:32:55 2005
@@ -58,7 +58,25 @@
             throw new IllegalStateException("Proxy not returned. Target " + containerId +
" not started");
         }
         if (!iface.isAssignableFrom(proxy.getClass())) {
-            throw new ClassCastException("Proxy does not implement expected interface " +
iface);
+            Class proxyClass = proxy.getClass();
+            Class[] interfaces = proxyClass.getInterfaces();
+            StringBuffer message = new StringBuffer();
+            boolean namesMatch = false;
+            for (int i = 0; i < interfaces.length; i++) {
+                Class anInterface = interfaces[i];
+                if (iface.getName().equals(anInterface.getName())) {
+                    namesMatch = true;
+                    message.append("Proxy implements correct interface: ").append(iface.getName()).append(",
but classloaders differ\n");
+                    message.append("lookup interface classloader: ").append(iface.getClassLoader().toString()).append("\n");
+                    message.append("target interface classloader: ").append(anInterface.getClassLoader().toString()).append("\n");
+                    message.append("target proxy classloader: ").append(proxy.getClass().getClassLoader());
+                    break;
+                }
+            }
+            if (!namesMatch) {
+                message.append("Proxy does not implement an interface named: ").append(iface.getName());
+            }
+            throw new ClassCastException(message.toString());
         }
         return proxy;
 



Mime
View raw message