File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes Why do I get those exceptions? Please HELP.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Why do I get those exceptions? Please HELP...." Watch "Why do I get those exceptions? Please HELP...." New topic
Author

Why do I get those exceptions? Please HELP....

Yaroslav Chinskiy
Ranch Hand

Joined: Jan 09, 2001
Posts: 147
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
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

As soon as I set the classpath and security.policy, everything worked out fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why do I get those exceptions? Please HELP....
 
Similar Threads
HFJ - RMI issues.
can't run the server of the rmi??
java.rmi.UnmarshalException?
unable to run server
java.rmi.UnmarshalException?