• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at the -Djava.rmi.server.codebase=XXX property to specify the location of the class files.
 
Yaroslav Chinskiy
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

As soon as I set the classpath and security.policy, everything worked out fine.
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic