• Post Reply Bookmark Topic Watch Topic
  • New Topic

RMI UnmarshalException

 
Dan Lynch
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

Can anyone help me with this...I am trying to run the sample RMI program I got from a site, Hello world. I get to the stage of starting the server and I get the following error

java.rmi.UnmarshalException: Error unmarshaling return header; nested exception is:
java.net.SocketException: Connection reset
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:203)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:350)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:160)
at HelloServer.main(HelloServer.java:9)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:222)
at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
at java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2150)
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2163)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2631)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:734)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:253)
at sun.rmi.server.MarshalInputStream.<init>(MarshalInputStream.java:110)
at sun.rmi.transport.ConnectionInputStream.<init>(ConnectionInputStream.java:38)
at sun.rmi.transport.StreamRemoteCall.getInputStream(StreamRemoteCall.java:111)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:197)
... 4 more

Am I using the incorrect port for the connection or something? I believe it runs on 1099. Im really not sure why this is not working, any help is much appreciated.

Cheers
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan,
Post the command used to start the server, and the code of the "main()" method in your "HelloServer" class (and I may be able to help you further).

Good Luck,
Avi.
 
Dan Lynch
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

This is the main method inthe HelloServer class

public static void main (String[] argv) {
try {
Naming.rebind ("Hello", new Hello ("Hello, world!"));
System.out.println ("Hello Server is ready.");
} catch (Exception e) {
//System.out.println ("Hello Server failed: " +
e.printStackTrace();
}
}

I hope this helps.
 
Dan Lynch
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh sorry and I used the rmiregistry &
and then java HelloServer &
 
Rebecca Hopper
Ranch Hand
Posts: 38
Eclipse IDE jQuery Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you may be missing some things from your main method. My remote interface is named Send, and my implementation class is RemoteServer, and this will start up with command java RemoteServer:

public static void main(String[] args){
if(System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
String name = "Send";
try {
RemoteServer obj = new RemoteServer();
try {
Send remoteServer = (Send) UnicastRemoteObject.exportObject(obj);
} catch (ExportException e){
//Object ID already in use
Send remoteServer = (Send) obj.getRef();

}
System.out.println("RemoteServer obj exported...");
//Bind the remote object's stub in the registry
System.out.println("Locating registry...");
Registry registry = LocateRegistry.getRegistry();
System.out.println("Registry located, binding RemoteServer...");

registry.bind(name, obj);
//Naming.rebind(name, remoteServer);
System.out.println("RemoteServer bound");
} catch (java.rmi.AlreadyBoundException e){
System.out.println("Already Bound: " + e.getMessage());
} catch (java.rmi.RemoteException e) {
System.out.println("Cannot create remote server object");

}
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dan,
I'm really sorry, I completely forgot about you -- but I see someone has helped you (eventually), anyway.

I'm guessing that you didn't create a "stub" class. The stub class is generated via the "rmic" utility. For your information, allow me to recommend the following Web page for learning RMI. It is what I learned from, and I think it is very good.

http://www.dickbaldwin.com/tocadv.htm

RMI starts at lesson 600.

Good Luck,
Avi.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!