Announcement Announcement Module
No announcement yet.
singletons in Spring context and MessageDrivenContext Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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).


    • #3
      ok, now i get it (classloader vs VM).