I have a framework that generates a class implementing a specified interface for populating javabean properties. I have the following code:
ClassPool pool = ClassPool.getDefault();
pool.insertClassPath( new ClassClassPath(PropertyPopulator.class) );
Loader loader = new Loader( PropertyPopulator.class.getClassLoader(), pool );
CtClass cc = pool.makeClass( "org.aom.chameleon.utils." + mapping.getName().replace( ' ', '_' ) + "Populator" );
loader.delegateLoadingOf( "org.aom.chameleon.utils.PropertyPopulator" );
loader.delegateLoadingOf( mapping.getEntityClass() );
cc.setSuperclass( pool.get( "org.aom.chameleon.utils.PropertyPopulator" ) );
and all of this compiles and returns the generated class just fine. The problem is that the generated class casts an object supplied to it to a specific class and then invokes the various setXXX() methods on it. The object that is being cast however implements several interfaces and extends a class (it is a JAXB generated class), and the error I'm getting is:
class com.uuic.ets.common.organization.impl.OrgUnitImpl does not implement interface com.uuic.ets.common.organization.OrgUnitType]: java.lang.IncompatibleClassChangeError: class com.uuic.ets.common.organization.impl.OrgUnitImpl does not implement interface com.uuic.ets.common.organization.OrgUnitType
The class being cast to is an OrgUnit which extends OrgUnitType (both interfaces) with the implementing class being the OrgUnitImpl. I am running this in WebSphere 5.1, so I am assuming this is some kind of classloading problem with the webcontainer. I have tried casting it directly to the impl class with no success as well as chaning the classloader structure via the websphere admin console.
I suppose I could overcome this via reflection, but the whole point of it was to get away from the overhead of reflection so I don't want to go that route.
Any other thoughts here?
Thanks...