-
1. Re: ClassNotFoundException loading an array type using URLCl
mclark00 Apr 20, 2004 9:37 PM (in response to mclark00)In case anyone has this same problem, this ended up being a JVM bug (in my opinion) that was exposed by the way JBoss was loading classes. Basically the ClassLoader.loadClass(String) method doesn't work consistently for loading array types, especially when the array's component type hasn't already been loaded. In other words, if y ou just try this code:
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Class clazz = loader.loadClass("[Ljava.lang.Integer;");
it would give you a ClassNotFoundException. If you added the following line directly above that code:
Integer[] intArray = new Integer[]{};
the classloader would be able to load that class.
The problem in JBoss is that org.jboss.invocation.MarshalledValueInputStream in 3.2.1 only uses the ClassLoader.loadClass(String) method to resolve classes, and doesn't fall back to the Class.forName(String) method, as Sun has now advised.
This has apparently been fixed in JBoss 3.2.3, although I'm not sure which build.
Just FYI, this same problem appears in WebStart. The JNLPClassLoader won't be able to load via the array syntax unless you use the above workaround to instantiate that class yourself. How's that for Sun's right hand not knowing what the left is doing ;)
Thanks,
Matt