tags:

views:

68

answers:

3
+2  A: 

What you are trying to do is very inefficient and not a very good idea. Basically you can send anything in a method invocation that you can serialize. If you want good performance, I would suggest that you only have one remote object that represents your service and acts as a facade for all the services that you need (each remote object results in separate file descriptor, so having lots of remote objects is typically not a good idea). Additionally, if you are frequently adding and removing objects, then sending a message every time you add or remove an element is not really sensible. I would suggest having a single remote object with the following two very simple methods:

LinkedList retrieveLinkedListByName(String);
boolean commitNewVersionOfLinkedListByName(String,LinkedList);

On application startup, you can download the linked list, and then at regular intervals and at application exit, you can send back the linked list. That should be more efficient then using the network every time you add or remove an element to your linked list. As long as the elements of your LinkedList are serializable, you don't need to do any magic (like extending remote) for it be sent.

Michael Aaron Safyan
Hey Michael, thanks for the response. But I'm only trying to understand the concepts. The way I specified it - how would you go about doing it, so that each time something is changed it's transmitted to the server, albeit being very inefficient?
+2  A: 
java.lang.ClassCastException: MyList_Stub cannot be cast to java.util.LinkedList
at $Proxy0.createList(Unknown Source)
at RemoteProgram.main(RemoteProgram.java:27)

LinkedList is a concrete class, RMI works with interfaces so you should be casting to the List interface on the client side.

darri
...as for the connection refused exception, I'd start by looking into the security policy you are using (assuming no external issues such as firewalls).
darri
A: 

Agree with the other posters, this is a very inefficient design.

As for your exceptions, I don't see know how you can get a 'connection refused' in the server and still be able to run the client. You would need to post the stack trace.

EJP