• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI Problem

 
Ranch Hand
Posts: 176
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Glen Iris
Ranch Hand
Posts: 176
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As always, Roel to the rescue.

Thank you once again sir.
 
Ranch Hand
Posts: 159
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did it solve your problem?
 
Glen Iris
Ranch Hand
Posts: 176
Netbeans IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic