wood burning stoves 2.0*
The moose likes Distributed Java and the fly likes Spurious ClassCastException and Connection refused in RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Spurious ClassCastException and Connection refused in RMI" Watch "Spurious ClassCastException and Connection refused in RMI" New topic
Author

Spurious ClassCastException and Connection refused in RMI

Joe Coughlin
Greenhorn

Joined: Jun 16, 2005
Posts: 2
This problem has perplexed us for a few weeks now. We have a server with multiple clients. I receive data from an outside source to feed the server, which then distributes the data to the clients via a listener-notifier pattern. I have a limited number of clients (4-6). Each client which registers to the server is on a separate thread to receive the data to eliminate any bottlenecks in processing. The server puts copies of the data to each client thread in a queue for sending out via RMI. The Thread then takes the data from the queue (a Vector) and sends to the clients.

Most of the time this works great. On occasion, We get a ClassCastException when sending the data to the clients. It seems this can be resolved by resending the data, but that is not satisfying as I don't want to be masking a more serious problem. This does not occur for all threads, the same data can be sent to the first 3 clients without problem, but the last one (and it always appears to be the last on in the list of Threads) gets the ClassCastException.

Any thoughts? The fact that is works most of the time is disturbing. Could this be a Threading issue? Examining the data does not reveal any issues with it. Obviously it is serialized or it would not work on the other Threads.

Another related issue dealing with the same code is that occassionally the Threads will get a Connection Refused RMI error. Again, not all the time, but only occasionally. And, not for all clients. Unfortunately, attempting to resend does not work for this case. After 3 tries, the data are dropped. This is the more insidious of the two issues. What causes this?

I'm using jdk1.5_01. This fails for both WinXP and Solaris 9 (and not Solaris connecting to XP via RMI, but two separate client-server configurations). The data are sent over a GigE link and the network loading is minimal.

Any insight would be greatly appreciated!
Arun Subbu
Greenhorn

Joined: Aug 30, 2003
Posts: 25
Hi Joe
Were you able to find any solution for the connection refused issue. I am also running into the same issue.Basically this is my scenerio.
I have an application that has a RMI object(call it server app). It will launch other processes, and they in turn will talk to the RMI object.(call them client apps).
The RMI server and the client appliacations are running for a long time.(overnight).The clients has timed out(meaning they were connected to Network Elements and timed out) and I close them. And again start them from the server app. The JVMs are launched, but when they try to talk to the RMI object in the server app, I get the connection refused.(Happens for my clients; but I cannot reproduce here at my development or test pcs)
I read the sum.rmi.transport.tcp.readTimeout is set to 2 hours default. I tried tweaking this(I reduced it 5 minutes) to see whether I can reproduce,but no use.
Any help would be really appreciated.

Thanks,
Arun.
 
jQuery in Action, 2nd edition
 
subject: Spurious ClassCastException and Connection refused in RMI
 
Similar Threads
Implementing java server
Multi-threading the RMI DataServer
RandomAccessFile & Threading
How to break blocked write operation???
Anybody interested in a sockets discussion ?