Witam.
Napisałem w Netbeans 5.0 prosty serwer RMI:
import java.rmi.RemoteException;
import javax.naming.*;
/**
*
* @author Black
*/
public class RMIServer {
/** Creates a new instance of RMIServer */
public RMIServer() {
}
public static void main(String args[]){
try {
ServerObjImpl obj1 = new ServerObjImpl("Przykładowy Obiekt");
Context Con = new InitialContext();
Con.bind("rmi:przyklad", obj1);
} catch (RemoteException ex) {
ex.printStackTrace();
} catch (NamingException ex) {
ex.printStackTrace();
}
}
}
Interfejs który służy do "komunikacji":
import java.rmi.Remote;
import java.rmi.RemoteException;
/**
*
* @author Black
*Interfejs dla Obiektu zdalnego.
*/
public interface ServerObj extends Remote {
/**
* zwraca wiadomoscz obiektu zdalnego.
*/
public String getMessage() throws RemoteException;
}
Oraz obiekt, który implementuje ten interfejs:
import java.rmi.server.UnicastRemoteObject;
import java.rmi.RemoteException;
/**
*
* @author Black
*/
public class ServerObjImpl extends UnicastRemoteObject implements ServerObj {
/** Creates a new instance of ServerObjImpl */
public ServerObjImpl(String message) throws RemoteException{
this.message = message;
}
public String getMessage(){
return this.message;
}
private String message;
}
Uruchamiam usluge rmiregisrty w windows.
Opdalam server i...
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: ServerObj]
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:122)
at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:208)
at javax.naming.InitialContext.bind(InitialContext.java:359)
//......itd.
Gdy ponadto wykonuje polecenie rmic ServerObjImpl i dostaje plik _Stub i _Skel.
Odpalam znowu server z lini polecen i mam to samo, ale rozni sie jednym szczegolem:
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: ServerObjImpl_Stub]
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:122)
at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:208)
at javax.naming.InitialContext.bind(InitialContext.java:359)
at RMIServer.main(RMIServer.java:28)
Moze mi ktoś pomóc, o co tu kurde biega?
Z góry dzięki i Pozdrawiam.