aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "RMI Problem" Watch "RMI Problem" New topic
Author

RMI Problem

Glen Iris
Ranch Hand

Joined: Jul 13, 2011
Posts: 157

Hey Folks,

I have a singleton class which is responsible for reading and writing to the database file named DatabaseAccess.

When a class connects to my Server via RMI, it is given an instance of a class named ControllerImpl. ControllerImpl has my business logic (book, return, search etc).

ControllerImpl creates an instance of ContractorManagerImpl. ContractorManagerImpl has an instance of a class named Data.

Data is the class which implements the sun provided interface. Data's methods call those of DatabaseAccess.

In the main class of my application, when I start my server, and then start a remote client. The GUI successfully reads/writes to the database.

However, if I then try to start another client, no data is returned from the database. For the second client, all of the static variables of my singleton(DatabaseAccess) are null. These variables are the database index file, the lock for the index file.

In the scenario which I have just described, does anything scream at you as being completely irrational?

Thanks,

G


OCPJP 6, OCMJD (2/3)
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4351

I don't know if it's related, but if you have a singleton DatabaseAccess, why would you have static variables in this class? Because of the design, there will be just one instance of these variables even if you just use instance variables.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Glen Iris
Ranch Hand

Joined: Jul 13, 2011
Posts: 157

As always, Roel to the rescue.

Thank you once again sir.
Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 126

Did it solve your problem?


SCJP, SCWCD, SCJD
Glen Iris
Ranch Hand

Joined: Jul 13, 2011
Posts: 157

I sure did pal. Roel provided the inspiration. I was also having problems which were caused by trying to make the Remote object invoke the the remote implementation class' methods rather than the interfaces methods.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI Problem
 
Similar Threads
Final design
Using Properties File to set database path
UrlyBird - RMI server and Data design issues
Making Data class Singleton.. Providing the database consistency problem?
B&S 2.2.2. - Thread Safe Access to File