Very strange cast Casting Exception in EJB (URLClassLoader)
Hello all,
we have developed a J2EE application with a very simple Stateless bean and an application client.
We are trying to create a pluginSystem that will be accessed by the bean. All plugins implement an interface so the bean doesn't need to know the concrete class and can use them casting to the interface.
The problem comes here:
We use URLClassLoader to load a concrete implementation of a Plugin but when casting to the interface a ClassCastExceptions is thrown.
URL[] u =new URL[1];
u[0] =new File(this.plugin_impl_folder).toURL();
URLClassLoader cl =new URLClassLoader(u,ClassLoader.getSystemClassLoader());
Object obj = cl.loadClass("pluginImpl." + p.getImplementedBy()).newInstance();
pluginImplementation pi = (pluginImplementation)obj;//Error comes here
This code works fine when executed locally but fails when being called by the session bean.
It seems that although "obj" is a concrete implementation of the interface "pluginImplementation" it cannot be casted.
Any suggestions?

