tags:

views:

19

answers:

0

Hi,

I am using apache.xmlrpc. I have an XML-RPC server running on several hosts, each server does things like restarting IPs connected to the host. This works fine with an individual server but I want to be able to specify multiple host IP addresses to the client which will create a thread, connect to each server and perform the same thing on all the servers. However, the way that it works now, the 2nd (or later) IP does not connect. Here is the client code:

public class SBCMSClientThread implements Runnable{

private String ip, method, className;
private Vector params = new Vector();

SBCMSClientThread(String ip){
    this.ip = ip;
}

@Override
public void run(){
    try {
        XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
        config.setServerURL(new URL("http://" + ip + ":8080/"));
        XmlRpcClient client = new XmlRpcClient();
        client.setConfig(config);
        params.add(0, method);

        System.out.println("Connecting to " + ip);
        Object[] result = (Object[]) client.execute("SBCHandler.getAndRunMethod", params);
        for (int i = 0; i < result.length; i++) {
            System.out.println(result[i].toString());
        }
    }
    catch (Exception exception) {
        System.err.println("JavaClient: " + exception + " " + ip);
    }
}