Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.io.OptionalDataException  RSS feed

 
mupparaju srinivasa rao
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I got an exception while reading data from server.I am using swing client and rmi.I am using IPlanet web server and servlets.Jdk version is 1.4.2_05

The exception is given below:
error unmarshalling return; nested exception is:
java.io.OptionalDataException.

Could any one explain.

I am attaching the folloowing code
The following method is from RemoteListener class
public void run() {
Vector sessions = null;
boolean conn = true;
try {
while (conn) {
sessions = remoteSystemManager.getSessionStatus();
for (int i = 0; i < sessions.size(); i++) {
SessionEvent evt = (SessionEvent) sessions.elementAt(i);
switch (evt.getEventType()) {
case SessionEvent.ADD :
mf.sessionAdded(evt);
break;
case SessionEvent.REMOVE :
mf.sessionRemoved(evt);
break;
case SessionEvent.EXPIRE :
mf.sessionExpired(evt);
break;
default :
break;
}
}
Thread.sleep(sleepTime);
}
} catch (java.rmi.RemoteException re) {
re.printStackTrace(System.err);
mf.alertDisconnection();
conn = false;
} catch (Exception e) {
}
}
}



The getSessionStatus method calls the beloe method which is from RemoteSystemimpl_stub class which is given below.



public java.util.Vector getSessionStatus()
throws java.rmi.RemoteException
{

try {
if (useNewInvoke) {

Object $result = ref.invoke(this, $method_getSessionStatus_22, null, 5332006586607892842L);
return ((java.util.Vector) $result);
} else {
java.rmi.server.RemoteCall call = ref.newCall((java.rmi.server.RemoteObject) this, operations, 22, interfaceHash);
ref.invoke(call);
java.util.Vector $result;
try {

java.io.ObjectInput in = call.getInputStream();
$result = (java.util.Vector) in.readObject();
for (int i = 0; i < $result.size(); i++) {
SessionEvent evt = (SessionEvent) $result.elementAt(i);

} catch (java.io.IOException e) {
throw new java.rmi.UnmarshalException("In stub error unmarshalling return,getSessionStatus()", e);
} catch (java.lang.ClassNotFoundException e) {
throw new java.rmi.UnmarshalException("error unmarshalling return", e);
} finally {
ref.done(call);
}
return $result;
}
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.rmi.RemoteException e) {
throw e;
} catch (java.lang.Exception e) {
throw new java.rmi.UnexpectedException("undeclared checked exception", e);
}
}

In the above code the invoke method is throwing exception.








when i am deleting the user and reconnecting the same user automatically the administrator application is throwing the following message and getting disconnected.
When the application is running it is throughing the following exception
Fri, 11 Feb 2005 11:19:42 GMT+05:30 - RemoteConnectionListener java.rmi.RemoteException re)error unmarshalling return; nested exception is: java.io.OptionalDataException
Thanks,

[ February 13, 2005: Message edited by: mupparaju srinivasa rao ]

[ February 14, 2005: Message edited by: mupparaju srinivasa rao ]

[ February 15, 2005: Message edited by: mupparaju srinivasa rao ]
[ February 15, 2005: Message edited by: mupparaju srinivasa rao ]
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the Java API Doc for OptionalDataException says:


Exception indicating the failure of an object read operation due to unread primitive data, or the end of data belonging to a serialized object in the stream. This exception may be thrown in two cases:

* An attempt was made to read an object when the next element in the stream is primitive data. In this case, the OptionalDataException's length field is set to the number of bytes of primitive data immediately readable from the stream, and the eof field is set to false.
* An attempt was made to read past the end of data consumable by a class-defined readObject or readExternal method. In this case, the OptionalDataException's eof field is set to true, and the length field is set to 0.

It sounds like you are expecting some data to be showing up and it's not being sent. You didn't give many details as to what your application is doing, and since you mentioned RMI and servlets, two very different technologies, I think we need some more detail. Perhaps some SMALL code samples.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!