Thank you darranl. I tried the workarounds suggested in the bug description and is able to call the PortableRemoteObject.narrow method. But when I call the create of the casted object method I get the following error message. The same piece of code works find if I call BeanB from a separate server.
javax.ejb.EJBException: Invalid invocation, check your deployment packaging
This is the code I am using to get a remote reference.
env = new Properties(); env.put(Context.PROVIDER_URL, "jnp://host:1099"); ic = new InitialContext(env); Object objref = ic.lookup("BeanB"); Object obj = PortableRemoteObject.narrow(objref, bean_b_package.IBeanBRemoteHome.class); home = (bean_b_package.IBeanBRemoteHome) obj; isc = home.create(); // error occurs here
are the ejbs deployed inside an ear archive? if yes, are they scoped?
Yes. The ejbs are deployed inside a jar which in turn is packaged in an ear file and are scoped. Both application A and B are scoped (I think...). The following are the settings in the application.xml of the two ears.
Application A <?xml version="1.0" encoding="UTF-8"?> <jboss-app> <loader-repository>localhost:Aloader=A.ear</loader-repository> </jboss-app> Application B: <?xml version="1.0" encoding="UTF-8"?> <jboss-app> <loader-repository>localhost:Bloader=B.ear</loader-repository> </jboss-app>
go read this: http://www.jboss.org/wiki/Wiki.jsp?page=HotDeployClassCastExceptions
more or less same situation as this - basically, you need to pull out the local/home interfaces and any other dependent classes for those ejbs and package them outside of both of those ears.
you could also turn on "pass by value" for ejb invocations, but that reduces your performance dramatically.
from my experiences, scoping works best if you have a stand alone legacy application that has older/incompatible library dependencies (i'm sure there are other useful scenarios too, but i have not stumbled across them yet).
if you have the jboss admin book, read chapter 2, it talks all about how the classloader works.