Results 1 to 3 of 3

Thread: singletons in Spring context and MessageDrivenContext

  1. #1
    Join Date
    Mar 2009
    Posts
    7

    Default singletons in Spring context and MessageDrivenContext

    i have a webapp that uses mdb's and is deployed to an ear. in my spring context i have some beans defined as singletons.

    everything works fine, just one thing puzzles me - i inserted a breakpoint in a constructor of a class, that is supposed to be a singleton (in terms of a spring bean).
    the breakpoint worked when context was loading - this is what i expected - and then between calls to setMessageDrivenContext and onMessage.
    how come? why is the context built more than once? can't the MessageDrivenContext share beans with Spring? that looks to be an efficiency hit, creating all the beans all over again for each MDB. as i see, this happens only when an mdb is initiated, but still, what if one has many MDBs?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    I suspect either something wrong with your configuration or usage of spring inside MDB. Also make sure the jars needed are located on the correct level (a singleton is a singleton per classloader NOT per VM).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Mar 2009
    Posts
    7

    Default

    ok, now i get it (classloader vs VM).
    thx!

Posting Permissions

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