Use classloading in server-side invokers
Remoting implements an optional remote classloading facility that makes it possible for a client invoker unmarshaller to request copies of classes that it encounters during the deserialization process. This facility is provided by a special org.jboss.remoting.transport.Connector that runs an org.jboss.remoting.ServerInvocationHandler designed to locate and return requested classes. This facility is enabled by configuring a Connector with the parameter org.jboss.remoting.InvokerLocator.LOADER_PORT (actual value "loaderport") set to an available port number. (See Configuration for more on configuration options.) Using the "loaderport" parameter will result in the creation of a second Connector which responds to requests to download classes. Prior to Remoting release 2.4.0.SP1, the classloading search implemented by the classloading SerrverInvocationHandler was the following: try system classloader, which loads from locations specified in the classpath; try the Remoting classloader, that is, the classloader that loaded the Remoting classes (which, depending on the context, may or may not be the system classloader). This original behavior is too restrictive in the context of the rich classloading options of the JBoss Application Server. As of release 2.4.0.SP1, it is possible to configure the classloading facility with a list of additional classloaders. One option is to pass a list of classloaders to a Connector programatically using the org.jboss.remoting.Remoting.Remoting.REMOTE_CLASS_LOADERS parameter (actual value "remoteClassLoaders") in either a configuration map or an org.jboss.remoting.ServerConfiguration. For example: ServerConfiguration serverConfiguration = new ServerConfiguration("socket"); Map invokerLocatorParameters = new HashMap(); invokerLocatorParameters.put(InvokerLocator.LOADER_PORT, "5544"); serverConfiguration.setInvokerLocatorParameters(invokerLocatorParameters); Map serverParameters = new HashMap(); ArrayList classLoaders = new ArrayList(); classLoader1 = ... classLoader2 = ... classLoaders.add(classLoader1); classLoaders.add(classLoader2); serverParameters.put(Remoting.REMOTE_CLASS_LOADERS, classLoaders); serverConfiguration.setServerParameters(serverParameters); connector = new Connector(); connector.setServerConfiguration(serverConfiguration); An alternative in the presence of the JBoss microcontainer, e.g., in the Application Server, would be to achieve the same result declaratively. For example: socket loaderport 5544 remoteClassLoaders ear1:classloader ear2:classloader ...