Announcement Announcement Module
No announcement yet.
How to create app.context even when some bean creation fails Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to create app.context even when some bean creation fails


    I use RmiProxyFactoryBean for using RMI services in my web app. Those services are used for DB synchronization which is triggered by TimerTasks from time to time.

    I want my application to be able to start up even when the remote services are not available. I have marked the remote service beans as lazy-init="true" and with this setup it is possible to create the context using ClassPathXmlApplicationContext() from my unit tests even without the remote connection.

    But when the application context is created from my web app using ContextLoaderListener filter and WebApplicationContextUtils.getWebApplicationContex t() it fails. It seems it is ignoring the lazy-init flag. :?

    How to ensure the creation of application context even if some "non mandatory" beans creation fails?


  • #2
    The lazy-init flag is never ignored, but keep in mind that if some other bean, which iitself a singleton and thus pre-iinitialized is referring to the lazy-init one, the lazy-init one will have to be created at that time as well. I think in your real (as opposed to unit test) setup, you have another bean referring to the rmi proy bean.

    One option would be to set this other bean to be lazy as well, but that really depends on your use case...