나는 꽤 기본적인 RMI에 노력하고 있습니다 :Java RMI InitialContext : LocateRegistry.createRegistry (int)와 동일합니까?
차질없이 작동하지만, 미래의 목적을 위해, 내가InitialContext
를 사용할 필요가
// Context namingContext = new InitialContext();
Registry reg = LocateRegistry.createRegistry(9999);
for (int i = 0; i < objs.length; i++) {
int id = objs[i].getID();
// namingContext.bind("rmi:CustomObj" + id , objs[i]);
reg.bind("CustomObj" + id , objs[i]);
}
.
Context namingContext = new InitialContext();
for (int i = 0; i < objs.length; i++) {
int id = objs[i].getID();
namingContext.bind("rmi:CustomObj" + id , objs[i]);
}
하지만이 기능을 사용할 수 없습니다. 명령 줄에서 rmiregistry
을 시작했습니다. LocateRegistry.createRegistry(int)
과 동일한 항목이 있습니까? 또는 내 수업에서 InitialContext
에 의해 사용 된 RMI 레지스트리/레지스트리를 시작하는 다른 방법은 없을까요?
(대신 명령 행의) 스택 추적 :
javax.naming.CommunicationException [Root exception is java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: bguiz.scratch.network.eg.Student]
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:126)
at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:208)
at javax.naming.InitialContext.bind(InitialContext.java:400)
at bguiz.scratch.RMITest.main(RMITest.java:29)
Caused by: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: bguiz.scratch.CustomObj
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:396)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:250)
....(truncated)
편집 : 이것에 아무 대답도 할 수없는 것으로 보인다 나는 몇 일에서 내 자신의 질문을 삭제합니다 (나 자신을 알아낼 수 없었다). 어떤 비터에 대한 마지막 호출!
@EJP 스택 추적을 내 질문에 추가했습니다. 또한이 클래스는 서버에서 실행되므로 URL을 지정할 필요가 없습니다 (로컬 호스트). 클라이언트는 URL을 지정해야하고 동일한 컴퓨터에서 샌드 박싱을하고 있기 때문에''rmi : // localhost : 1099/"'를 지정하지만이 클래스는 실행에 실패하므로 아직 멀었습니다 . – bguiz