This content has been marked as final.
Show 2 replies
-
1. Re: EJB Client Classpath
kiwiclive Oct 6, 2005 11:49 AM (in response to kalyan120)Hi Kaylan,
My understanding is that the client must have copies of the home and component interfaces. You do not need the bean class (and would not provide that as it contains your business logic).
Cheers,
Clive -
2. Re: EJB Client Classpath
kalyan120 Oct 6, 2005 12:43 PM (in response to kalyan120)Thanks. I'm aware of the fact that bean class is not needed on the client side. One doesn't have to always have the remote and home interface classes on the client side. For example, the following code works pretty well without those interfaces on the client side (since there is no direct reference for the interface in the code):
Object obj = context.lookup("server.Server"); Method m = obj.getClass().getDeclaredMethod("create",null); Object remote = m.invoke(obj,null); Method rm = remote.getClass().getDeclaredMethod("getInformation",null); Object result = rm.invoke(remote,new Object[]{queueName}); System.out.println("Information the other way: "+result);
In this case the proxy's instance representing the ServerHome (and I believe it implements this interface as well) gets downloaded to the client and along with its codebase annotation pointing to the codebase of the Jboss server. Once it gets that, since it doesn't have the ServerHome interface's class definition, it downloads the definition from the server. Someone from JBoss or who knows the internals of it, please correct me if I'm wrong in my interpretation. I also believe that the RMIClassLoader is used to download the class definition from the codebase. When it was able to download the definition for a proxy, why was it not able to download it when I type cast the interface? (I have also tried setting the RMIClassLoader as the context class loader, with the appropriate code base, but still I get the NoClassDefFoundError.Thread.currentThread().setContextClassLoader(RMIClassLoader.getClassLoader("http://mymachine:8083/"));
I hope this makes my question clear now.
Thanks,
Kalyan.