• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Different ClassLoaders loading Singleton class

 
Saurabh Tandon
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a class based on Singleton pattern which is called by a RMI Server and another java class. The RMI Server loads the class using a class loader and the normal java class by another class loader, so in the end I have two instances of the same class, can any one suggest some work around for this problem I want only one instance of my class. I have thought of writing my own class loader is it a good way (if yes, what are pitfalls for the class loader I need to take care).
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay am not too clear about the question but i was just wondering..
if the class exists in the classpath of the rmi server in the same m/c then the am not so sure if 2 instances of the singleton can exist int he same vm that started the rml server in the first place.
Are you talking about a case where the class is loaded by another vm and rmi server loads it by doing a lookup and then loads the same class from within itself??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic