Dec 28th, 2009, 08:25 AM
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?
Dec 28th, 2009, 12:21 PM
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).
Dec 29th, 2009, 02:47 AM
ok, now i get it (classloader vs VM).