RpcDispatcher is hard-coded to use JGroups' classloader when marshalling the users's custom objects over RPC.
RpcDispatcher uses Util.objectFromByteBuffer to unmarshall, which uses an ObjectInputStream. ObjectInputStream uses the classloader of its caller's class (Util).
RpcDispatcher does allow a custom marshaller to be used (implementing RpcDispatcher.Marshaller), but since Util.objectFromByteBuffer hard-codes the use of ObjectInputStream, a custom marshaller cannot simply set the classloader and then delegate back to the default JGroups code.
Util.objectFromBuffer should be enhanced to use a custom ObjectInputStream implementation that overrides resolveClass to use a custom classloader, and an API should be added to RpcDispatcher to pass in the classloader to use.