Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI UnmarshalException

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh sorry and I used the rmiregistry &
and then java HelloServer &
 
Ranch Hand
Posts: 38
jQuery Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic