Announcement Announcement Module
Collapse
No announcement yet.
Multiple Singletons ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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.

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


        • #5
          Which version of Spring are you using?

          Comment

          Working...
          X