if they have different package names, then they are considered different classes.
Assume that both of clients call lookup method:
BeanA bean = (BeanA)context.lookup("BeanABean/remote"); bean.add(1,2);
The first of client is ok, but the second of client is fail and received some errors:
Exception in thread "main" java.lang.ClassCastException: $Proxy0
Error at line:
BeanA bean = (BeanA)context.lookup("BeanABean/remote");
I think that I must config my JBoss Server but I don't know where I do this.
what is the fully qualified class name of BeanA in both clients? i think the lookup is returning one version and you are casting it to the other version.
The first client:
The second client:
I were tried:
InitialContext ctx = new InitialContext(); my.com.BeanA bean = (my.com.BeanA)ctx.lookup("BeanABean/remote"); bean.hello();---> Ok!
InitialContext ctx1 = new InitialContext(); john.com.BeanA bean = (john.com.BeanA)ctx1.lookup("BeanABean/remote"); bean.hello();---> error!
right, which is completely normal. you can't map a JNDI name to two classes.
since JBoss does not use the package name as part of the default JNDI name, you will need to override it so your two classes get different JNDI names.