Friday, September 15, 2006

non singleton bean initialization

Bit me.
Sympton: javax.management.InstanceAlreadyExistsException
Cause: one singleton bean a was calling ApplicationContext.getBean(), while another web.xml defined non-singleton bean b was statically calling ApplicationContext.getBean(a)

Doh!

Moral: never load beans statically, put in initialization or class constructor

No comments: