Skip to main content

Java RMI - when trying to fetch class over RMI

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2012-08-18

Good afternoon,

I am trying to learn Java RMI.
I found a tutorial at which worked fine.

It works fine with methods returning BigInteger.
I added one method to server that should fetch a class to client.

But when trying to run the option 3 - Get TestClass from the client, I get this exception:

Exception in thread "main" java.rmi.UnmarshalException: error unmarshalling return; nested exception is: writing aborted; TestClass
at sun.rmi.server.UnicastRef.invoke(
at PowerServiceServer_Stub.get(Unknown Source)
at PowerServiceClient.main(
Caused by: writing aborted; TestClass
at sun.rmi.server.UnicastRef.unmarshalValue(
at sun.rmi.server.UnicastRef.invoke(
... 2 more
Caused by: TestClass
at sun.rmi.server.UnicastRef.marshalValue(
at sun.rmi.server.UnicastServerRef.dispatch(
at sun.rmi.transport.Transport$
at Method)
at sun.rmi.transport.Transport.serviceCall(
at sun.rmi.transport.tcp.TCPTransport.handleMessages(
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(
at sun.rmi.transport.tcp.TCPTransport$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

I am running server with this command:
java PowerServiceServer
And the client with this one:
java PowerServiceClient localhost

The java.policy file is also included in the attached rmitest.tar.gz.

We already tried to find out the problem with a friend, but we were not successful..

Thank you in advance for help.

rmitest.tar_.gz4.58 KB

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2012-08-18

OK, I found it out.

The class that I wanted to transfer - named TestClass in the attached sources - was not implementing Serializable interface. When I added "implements Serializable" to the class definition, it works fine now. I spent this afternoon by trying to find this out :)