This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes Different ClassLoaders loading Singleton class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Different ClassLoaders loading Singleton class" Watch "Different ClassLoaders loading Singleton class" New topic
Author

Different ClassLoaders loading Singleton class

Saurabh Tandon
Greenhorn

Joined: Oct 03, 2001
Posts: 1
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

Joined: Mar 06, 2001
Posts: 1209
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??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Different ClassLoaders loading Singleton class
 
Similar Threads
ClassLoaders
2 different types of singleton
Instance of Singleton pattern
How to restrict execution of same class from two different consoles at same time?
RMI issue