私はかなり基本的なRMIをしようとしています:
// 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] );
}
これは問題なく機能しますが、将来の目的のために、を使用する必要がありますInitialContext
。
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)
編集:これに対する答えがないように思われるので、私は数日以内に自分の質問を削除します(私はそれを自分で理解することができませんでした)。苦い人のための最後の呼び出し!