All,
I'm trying to run a
java RMI program,here is the error and below are all my file code,any help will be appreciated.
the exception is
================================
C:\java\rmi\projects\project2>java -Djava.security.policy=RMISecurity.poli
cy -cp c:\java\rmi\projects\project2 ServerProgram
java.rmi.ServerException: RemoteException occurred in server
thread; nested
exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested
exception is:
java.lang.ClassNotFoundException: RemoteInterfaceImpl_Stub
java.rmi.UnmarshalException: error unmarshalling arguments; nested exceptio
n is:
java.lang.ClassNotFoundException: RemoteInterfaceImpl_Stub
java.lang.ClassNotFoundException: RemoteInterfaceImpl_Stub
================================
ServerProgram
==============================
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
public class ServerProgram
{
public static void main(
String str[])
{
if(System.getSecurityManager() == null)
{
System.setSecurityManager(new RMISecurityManager());
}
try
{
RemoteInterfaceImpl r1 = new RemoteInterfaceImpl("Matt1",99,"Charlotte");
//RemoteInterfaceImpl r2 = new RemoteInterfaceImpl("Matt2",88,"Charlotte2");
//r1.setName("Matt1");
//r1.setAge(99);
//r1.setCity("Charlotte");
//r2.setName("Matt2");
//r2.setAge(188);
//r2.setCity("Charlotte2");
Naming.rebind("object1",r1);
//Naming.rebind("object2",r2);
System.out.println("Objects bound");
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
===========================
RMISecurity.policy
======================
grant codeBase
"file:/c:/java/rmi/projects/project2/"{
permission java.net.SocketPermission
"127.0.0.1", "accept, connect, listen, resolve";
};
==============================
RemoteInterfaceImpl
==================================
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class RemoteInterfaceImpl extends UnicastRemoteObject implements RemoteInterface
{
private String name;
private int age;
private String city;
public RemoteInterfaceImpl(String name,int age,String city) throws RemoteException
{
this.name=name;
this.age=age;
this.city=city;
}
public String getName() throws RemoteException
{
return this.name;
}
public int getAge()throws RemoteException
{
return this.age;
}
public String getCity() throws RemoteException
{
return this.city;
}
public void setName(String name) throws RemoteException
{
}
public void setAge(int age)throws RemoteException
{
}
public void setCity(String city) throws RemoteException
{
}
}