Announcement Announcement Module
No announcement yet.
Singleton - updating bean in app context fails Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Singleton - updating bean in app context fails

    I have an spring context file which is loaded in by a class (reads in the bean by adding the xml files to a classpathxml object, then using getBeanFactory().getBean().

    This returns a bean that has been defined in the xml file, however the bean is null. It seems spring is not creating the object?

    What I want, is to have a single object defined in the xml file, be able to get a handle to the bean, update properties in the bean (single instance) continue doing work elsewhere in the code and later on get a handle to the bean again and read off (or update) more properties.

    Am I approaching this the wrong way?
    In this instance, spring is not running in a web container, it is being loaded in a normal application.

  • #2
    Don't know about that classpathxml object. What I normally do is:

    BeanFactory bFac = new CassPathXmlApplicationContext("ApplicationContext. xml");
    MyBean bean = bFac.getBean("myBean");

    Other than that what you do sounds right. If this dosn't help, can we see your code?