Community
Participate
Working Groups
Build Identifier: tip of git Error message is java.lang.IllegalArgumentException: Object is not of type class org.eclipse.jetty.server.Server The error message should include the actual class found, and the most common error scenario (multiple jetty jars on classpath) Reproducible: Always
Suggested patch: diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index 6ba2729..b92b121 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -307,7 +307,7 @@ public class XmlConfiguration // Check the class of the object Class<?> oClass = (Class<?>)nodeClass(_config); if (oClass != null && !oClass.isInstance(obj)) - throw new IllegalArgumentException("Object is not of type " + oClass); + throw new IllegalArgumentException("Object is not of type " + oClass+". Actual type is "+obj.getClass()+". If names look the same there may be several jetty jar files on the classpath."); configure(obj,_config,0); return obj; }
thanks for the suggestion. I went with: if (oClass != null && !oClass.isInstance(obj)) { String loaders = (oClass.getClassLoader()==obj.getClass().getClassLoader())?"":"Object Class and type Class are from different loaders."; throw new IllegalArgumentException("Object of class '"+obj.getClass().getCanonicalName()+"' is not of type '" + oClass.getCanonicalName()+"'. "+loaders); }