ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gurdev Parmar" <>
Subject AntClassLoader leads to ClassCastException
Date Tue, 26 Feb 2002 21:06:25 GMT
I am using AntClassLoader in a method like this:

public TestClient createDynamically(String classname, AntClassLoader acl)
    Class clazz = acl.findClass(classname);
    return (TestClient) clazz.newInstance();

The method is invoked with classname as "TestEjbSelect".

Here, AntClassLoader, acl, has a classpath which contains the class
with the TestEjbSelect and TestClient. "TestClient" is the
super class of "TestEjbSelect".

I get a ClassCastException at the "return (TestClient) clazz.newInstance()"
point. When run in debug mode I can see that TestClient and TestEjbSelect
are being loaded from the ant loader.

Why am I getting the casting exception? I have attached the exception stack.

Thanks in advance,

View raw message