Hi!
I have an enterprise application A and B deployed (in WLS 10.0). A is the "framework", B is a client app. The client issues the following calls:
Object o = ctx.lookup(jndiName); // line 1
cf = (ConnectionFactory) o; // line 2
ConnectionFactory is an interface, defined as:
public interface ConnectionFactory
extends java.io.Serializable, javax.resource.Referenceable {
...
}
What happens is:
- If the jar containing the interface class is on the system classpath, line 2 is executed fine
- If the interface class is not on the system classpath, but packaged with the applications separately, line 2 throws a ClassCastException (which has the informative text that the o is a ConnectionFactoryImpl)
Why is this possible? I assume that the JNDI lookup returns only a stub to the remote object (am I right in this point?), then why does it matter if the classloader of the interface class are different?
The kind of answer I expect:
- Yes, it should happen the way you experience it, because ...
- No, it should not happen this way, because if ... then ..., so there is something fishy in your setup
- The situation you described is very strange, are you sure you don't miss some point somewhere?
- ... :)
It would also be nice if someone could clarify how the JNDI and stubs work, where does the casting happen (on the client side on the stub? or on the original object on the remote side?), etc.
Thanks for your help!