I'm still stuck with this bug. Its throwing a ClassCastException <MyRemoteObject_Stub> cannot be cast to <MyRemoteObject>
when I invoke Naming.lookUp(url) to get the remote object from the registry.
What do I do? I've tried virtually everything. Maybe I shouldn't have used RMI. I was very familiar with traditional sockets.
Thanks bartender, I've fixed the class cast issue and now the database gets across the wirw to the client side but there's another problem. Whenever i invoke a method like generateUniqueID(), the correct value is gotten at the client side but when I invoke the getInventory() method (which returns a Map<Integer, HotelRecord>), an empty Map is gotten on the client side and my hotel table controller relies heavily on this method to populate the JTable display, hence, a blank table. I have rescheduled because of thish issue. (the deadline is crazy, I thought I would be having a year, now school exam starts next week, I also have a digital circuit project to defend this week). How can I quickly get around this bug?
Are you using a thin or thick client approach? Anyway your map with <Integer, HotelRecord> pairs should not go to the client, because that makes no sense.
Sounds to me your application is quite buggy and you are fixing one bug and another is already there. Maybe you should re-evaluate your whole solution and approach. Your previous topic had as title "URLyBird, almost done, but some lil' probs here", the things you describe in these topics are not little problems but major issues!
I think I have the proper structure for rmi commiunication. A remote interface extending remote and serializable, an implementation class extending unicast remote object, exported using registry's rebind method, fetched at the other side using naming.lookup(). The class cast exception was me casting to the wrong type, sorry for raising uneeded alarm on that I used the same client for stand-alone and network and for stand-alone, its working fine. The map is a return value of one of the methods in the database. It only returns a copy of the actual map in the database not the real one (of course I know the implications of what you thought there Roel). It is the database that I exported with a wrapper (similar to exporting a factory that houses a single database -- my methods would then not be forced to include the throws clause for remote exeption, crappy shortcut there eh?). My approach is quite similar to that of Andrew Munkhouse in his SCJD book only that I extended the DB interface to add a few convinience methods. Data class passed locking Roberto's locking (with a hundred thousand threads, i was just having fun with threads ). Classes in the diferent packages are loosely coupled (so I can completely wipe out all the netwok stuffs without touching the GUI code). MVC employed in the JTable. It is only in the connectToDataSource(AppMode mode, Configuration config) that the GUI code obtains a reference of the database based on the application mode (local or network) and the rest of the system is not aware whether the database is local or remote.
That sounds indeed as a nice setup of your solution, but having your getInventory-method return an empty map when in networked mode is a big issue and a bit strange that you discovered this at the point you wanted to submit. I think you would have discovered this a whole lot faster.
Did you do some debugging yourself?
when server is started is the database file read correctly
when you invoke the getInventory from the client, what is the value of the map at the server? (I would guess it's an empty map too)