Hi all. I am writing simple server that will write all nessages send to it by a client to the System.out import java.rmi.server.*; import java.rmi.*; public class Logger extends UnicastRemoteObject implements RemoteLogger{ private String name = "Logger"; private String port = "1099"; private String host = "localhost"; public Logger() throws RemoteException{ super(); } public void log(Message msg) throws RemoteException{ System.out.println(msg.getMessage()); } public String getHost(){ return host; } public String getPort(){ return port; } public String getName(){ return name; } public void setHost(String host){ this.host = host; } public void setPort(String port){ this.port = port; } public void setName(String name){ this.name = name; } public void register(){ try { System.out.println("Registering server with rmiregistry");
Naming.rebind("rmi://" + getHost() + ":" + getPort() + "/" + getName(), this); System.out.println("Server Registered as " + getName()); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args){ try{ Logger logger = new Logger(); logger.register(); }catch(Exception e){ e.printStackTrace(); } } } ----------Message------- import java.io.*; public class Message implements java.io.Serializable{ private String message; private static long messageCount = 0; public Message(String message) { this.message = message; messageCount++; } public String getMessage(){ return new String("" + messageCount + " :-->" + message); } } ---- Remote Interface ----- import java.rmi.*; public interface RemoteLogger extends Remote { public void log(Message msg) throws RemoteException; } I compile the code, then use 'rmic Logger' to create stub then run Logger by typing - 'java Logger' I get the following output: 1 :-->Object logger was constracted Registering server with rmiregistry java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: Logger_Stub java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: java.lang.ClassNotFoundException: Logger_Stub java.lang.ClassNotFoundException: Logger_Stub at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245) at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:354) at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source) at java.rmi.Naming.rebind(Naming.java:160) at Logger.register(Logger.java:63) at Logger.main(Logger.java:82)
WHAT AM I DOING WRONG??? Thank you.
Doug Melzer
Ranch Hand
Joined: Mar 23, 2000
Posts: 51
posted
0
Take a look at the -Djava.rmi.server.codebase=XXX property to specify the location of the class files.
Yaroslav Chinskiy
Ranch Hand
Joined: Jan 09, 2001
Posts: 147
posted
0
As soon as I set the classpath and security.policy, everything worked out fine.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: Why do I get those exceptions? Please HELP....