Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Error unmarshaling return header; nested exception

843793May 28 2003 — edited May 28 2003
Hi,

I have written rmi code for implementing callbacks. but while registering the client object witht he server i am getting the exceptions
java.rmi.UnmarshalException: Error unmarshaling return header; nested exception
is:
java.io.EOFException
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:
203)

following is the code

Server code
package rmistock;

import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.LocateRegistry;
import java.util.*;

public class StockInfoImpl extends UnicastRemoteObject implements StockInfo, Runnable
{

private Vector clients = new Vector();

public StockInfoImpl() throws RemoteException { }

public void run()
{

int counter = 0;
while (true)
{

for (Enumeration e = clients.elements() ; e.hasMoreElements() ;)
{

// send an updated price for all stocks to each client
StockUpdate client = (StockUpdate) e.nextElement();
try
{
client.update("deepak", "" + counter);
counter++;
}
catch (RemoteException ex)
{
System.out.println("update to client " + client + " failed.");
try
{
unregister(client);
}
catch (RemoteException rex)
{
System.err.println("Big trouble.");
rex.printStackTrace();
System.exit(3);
}
}
}
// sleep for 5 second
try
{
Thread.sleep(5000);
}
catch (InterruptedException iex)
{
iex.printStackTrace();
}
}
}

public synchronized void register(StockUpdate o) throws RemoteException
{

if (!(clients.contains(o)))
{
clients.addElement(o);
System.out.println("Registered new client " + o);
}
}


public synchronized void unregister(StockUpdate o) throws RemoteException
{
if (clients.removeElement(o))
{
System.out.println("Unregistered client " + o);
}
else
{
System.out.println("unregister: client " + o + "wasn't registered.");
}
}

public static void main(String args[])
{
System.setSecurityManager(new RMISecurityManager());
StockInfoImpl sii = null;
try
{
//LocateRegistry.createRegistry(5001);
sii = new StockInfoImpl();
Naming.rebind("//192.168.52.102:5001/rmistock.StockInfo", sii);
}
catch (Exception e)
{
e.printStackTrace();
}
try
{
System.out.println("StockInfoImpl registered and ready");
Thread updateThread = new Thread(sii, "StockInfoUpdate");
updateThread.start();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}



Client code


package rmistock;

import java.net.URL;
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
import java.io.*;

public class StockWatchText implements StockUpdate, Serializable
{
public static void main(String args[])
{
String host = "192.168.52.102";
StockInfo stockInfo = null;
/*
if (args.length > 0)
{
host = args[0];
}
*/
StockWatchText swt = new StockWatchText();
try
{
UnicastRemoteObject.exportObject(swt);
}
catch(Exception ex)
{
System.out.println("error is here deepak test1 \n\n");
ex.printStackTrace();
}
String serverName = "//" + host + ":" + "5001" + "/rmistock.StockInfo";
try
{
stockInfo = (StockInfo)Naming.lookup(serverName);
}
catch(Exception ex)
{
System.out.println("error is here deepak test2 \n\n");
ex.printStackTrace();
}
try
{
stockInfo.register(swt);
}
catch (Exception e)
{

System.out.println("error is here deepak test3 \n\n");
e.printStackTrace();
System.exit(2);
}
}

public synchronized void update(String symbol, String price) throws RemoteException
{
System.out.println(symbol + ": " + price);
}
}

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 25 2003
Added on May 28 2003
1 comment
1,093 views