Multiple Singletons ?
I have a singleton with some post setup code that needs to be called so I am using:
But somehow in my application this is getting called twice ??! It is getting called twice from the same thread (tomcat/spring bootstrapping)
What are things to look out for to prevent this from happening...
Thanks in advance
Without getting more information it would be hard to tell. Does the object itself call the initialize method inside the Java code?
Could you post the declaration of the object from the XML file? And if its not too long, the object itself.
You could try the following piece of code:
Now you can see the stacktraces of the code that calls your init method.
throw new Exception();
... your code.
The only thing I could think of is the application context being loaded twice ormaybe you calling the initialise() method from somewhere else in the bean (afterPropertiesSet() method maybe)
Which version of Spring are you using?