-
Multiple Singletons ?
Hello,
I have a singleton with some post setup code that needs to be called so I am using:
init-method="initialise"
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
-Alan
-
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:
Code:
void yourInitMethod(){
try{
throw new Exception();
}catch(Exception ex){
ex.printStackTrace();
}
... your code.
}
Now you can see the stacktraces of the code that calls your init method.
-
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)
rgds,
Alef
-
Which version of Spring are you using?