Clustering - StringIndexOutOfBoundsException Exception
ganguri Aug 11, 2004 4:10 PMWe are clustering multiple instances of jboss. We are using RpcDispatcher to send the requests. When we try to make a method call on the client instances, they are throwing StringIndexOutOfBoundsException error, which is reflected in the server that tried to invoke the remote method.
The code we are using is as follows:
package com.test.cluster.jboss;
import org.jgroups.*;
import org.jgroups.blocks.*;
import org.jgroups.util.*;
//import java.util.ArrayList;
//
//import org.jboss.ha.framework.interfaces.*;
//import org.jboss.ha.framework.server.*;
import com.test.util.*;
//import java.lang.reflect.Method;
public class RpcDispatcherClient implements java.io.Serializable
{
private Channel channel;
private RpcDispatcher disp;
private RspList rsp_list;
private String props;
public RpcDispatcherClient() throws Exception
{
}
public RpcDispatcherClient(String key, String id) throws Exception
{
invoke(key, id);
}
private void invoke (String key, String id)throws Exception
{
System.out.println("Props: " + props);
/*
HAPartition hapi = new HAPartitionImpl("DefaultPartition", new JChannel(props), true);
hapi.registerRPCHandler("RpcDispatcherClient", this);
//String localIP = InetAddress.getLocalHost().getHostAddress();
System.out.println("########################## before callMethodOnCluster method call...");
System.out.println("########################## PartitionName: " + hapi.getPartitionName());
System.out.println("########################## clusterview id: " + hapi.getCurrentViewId());
ArrayList arr = hapi.callMethodOnCluster("CacheNotify", "invoke", new String[]{key,id}, true);
System.out.println("arr.size: " + arr.size());
System.out.println("########################## after callMethodOnCluster method call...");
*/
}
public void invokeCacheNotify(String key, String id) throws Exception
{
Notifiable notify = new Notify();
notify.invoke(key, id);
}
public void start(String key, String id) throws Exception
{
try
{
channel = new JChannel(props);
System.out.println("Is Channel connected? " + channel.isConnected());
if (!channel.isConnected())
channel.connect("DefaultPartition");
System.out.println("Channel name? " + channel.getChannelName());
disp = new RpcDispatcher(channel, null, null, this);
System.out.println("Server Object name? " + disp.server_obj.getClass().getName());
rsp_list = disp.callRemoteMethods(null, new MethodCall("invokeCacheNotify", new String[]{key,id}, new String[]{"java.lang.String","java.lang.String"}), GroupRequest.GET_ALL, 0);
channel.close();
disp.stop();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
try
{
new RpcDispatcherClient().start(args[0], args[1]);
}
catch(Exception e)
{
System.err.println(e);
}
}
}
The console output extract is:
15:48:15,346 INFO [UDP] unicast sockets will use interface 120.33.15.22
15:48:15,349 INFO [UDP] socket information:
local_addr=jbsprde22:33222, mcast_addr=228.1.2.3:45566, bind_addr=/120.33.15.22, ttl=32
socket: bound to 120.33.15.22:33222, receive buffer size=64000, send buffer size=32000
multicast socket: bound to 120.33.15.22:45566, send buffer size=32000, receive buffer size=64000
15:48:15,351 INFO [STDOUT]
-------------------------------------------------------
GMS: address is stage:33222
-------------------------------------------------------
15:48:20,572 INFO [DefaultPartition] New cluster view (id: 2, delta: 1) : [120.33.15.22:1199, 120.33.15.22:1299, 120.33.15.22:33222]
15:48:20,575 INFO [DefaultPartition:ReplicantManager] Dead members: 0
15:48:20,591 INFO [STDOUT] Channel name? DefaultPartition
15:48:20,601 INFO [STDOUT] Server Object name? com.test.cluster.jboss.RpcDispatcherClient
15:48:20,638 INFO [STDOUT] [sender=stage:33222], method_call: invokeCacheNotify(Test, 101010)
15:48:20,639 INFO [STDOUT] server_obj.getClass().getName()com.test.cluster.jboss.RpcDispatcherClient
15:48:20,641 INFO [STDOUT] Invoking Cache - clearing caches on key Test LocalIP 120.33.15.22 RemoteIP 120.33.15.22
15:48:20,647 ERROR [RequestCorrelator] error invoking method, exception=java.lang.StringIndexOutOfBoundsException: String index out of range: -1
15:48:20,722 INFO [DefaultPartition] New cluster view (id: 3, delta: -1) : [120.33.15.22:1199, 120.33.15.22:1299]
What is wrong with our code? Please help......