RMI Name.rebind() exception

Rui Wang Rui.Wang@newcastle.ac.uk
Sun Nov 6 14:56:00 GMT 2005


I am using GCJ 4.0.2 thisiscool compiled version for WinXP platform.
After compiled my RMI server, it fails to start, the error message is
the following:
F:\GCJTest\RMI\RMISimpleExample\server>GRMIServerImpl.exe
Binding server to rmi://localhost:1099/GRMISERVER...
Remote exception: java.rmi.UnexpectedException: undeclared checked
exception; ne
sted exception is:
 java.lang.ArrayIndexOutOfBoundsException: 1
java.rmi.UnexpectedException: undeclared checked exception; nested
exception is:
 java.lang.ArrayIndexOutOfBoundsException: 1
 at 0x004223fe (Unknown Source)
 at 0x00417702 (Unknown Source)
 at 0x0041a1e4 (Unknown Source)
My RMI Server code is: 
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
public class GRMIServerImpl extends UnicastRemoteObject
 implements GRMIServer
{
	GRMIServerImpl() throws RemoteException
	{
		super();
	}
	// remote method
	public int sum(int a,int b) throws RemoteException
	{
		return a + b;
	}
	private static final Class class4 =
java.rmi.server.RemoteStub.class;
	
	public static void main(String args[])
	{
		//set the security manager
		try
		{
			System.setSecurityManager(new
RMISecurityManager());
			java.rmi.server.RemoteStub GRMIServerImpl_Stub;
			
			//also this line return correct Class object:
			Class cls =
Class.forName("GRMIServerImpl_Stub");
			//create a local instance of the object
			GRMIServerImpl server = new GRMIServerImpl();
			
			//put the local instance in the registry
			String url = "rmi://localhost:1099/GRMISevice";
			
			System.out.println("Binding server to " + url +
"...");
			Naming.rebind(url, server);
			System.out.println("Server waiting.....");
		}
		catch (java.net.MalformedURLException me)
		{
			System.out.println("Malformed URL: " +
me.toString());
		}
		catch (RemoteException re)
		{
			System.out.println("Remote exception: " +
re.toString());
			re.printStackTrace();
		}
		catch(Exception ex)
		{
			System.out.println("Exception: " +
ex.toString());
			ex.printStackTrace();
		}
	}
}
The problem seems occur during Naming.rebind() method. Anyone knows what
caused this problem? 
Regards
Rui 


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /