Results 1 to 5 of 5

Thread: Multiple Singletons ?

  1. #1

    Default 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. #2
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    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.

  3. #3
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    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.

  4. #4
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    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
    Alef Arendsen
    SpringSource
    http://www.springsource.com

  5. #5
    Join Date
    Apr 2005
    Posts
    4

    Default

    Which version of Spring are you using?

Similar Threads

  1. not so Singletons, and Cyclic references
    By Ian Johnson in forum Container
    Replies: 0
    Last Post: May 23rd, 2005, 04:18 PM
  2. Replies: 3
    Last Post: Apr 21st, 2005, 03:19 PM
  3. Replies: 1
    Last Post: Mar 9th, 2005, 03:52 PM
  4. Replies: 1
    Last Post: Feb 25th, 2005, 07:12 AM
  5. Multiple Pages
    By afida in forum Swing
    Replies: 12
    Last Post: Feb 16th, 2005, 08:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •