Announcement Announcement Module
Collapse
No announcement yet.
Overriding singleton bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Overriding singleton bean

    I found that i can not register bean which already exists in xml:

    Error: java.lang.IllegalStateException: Could not register object [Configuration: core-default.xml, core-site.xml, mapred-default.xml, mapred-site.xml, yarn-default.xml, yarn-site.xml, hdfs-default.xml, hdfs-site.xml, job.xml] under bean name 'hadoopConfiguration': there is already object [org.springframework.data.hadoop.configuration.Conf igurationFactoryBean@7e4e194f]

    How to solve this? is there some way to unregister bean at runtime and then register a new one under same name?

  • #2
    changed code to:
    /* register hadoop configuration */
    springContext.getBeanFactory().destroyBean("hadoop Configuration", springContext.getBean("hadoopConfiguration"));
    springContext.getBeanFactory().registerSingleton(" hadoopConfiguration", conf);

    but still does not work

    Error: java.lang.IllegalStateException: Could not register object [Configuration: core-default.xml, core-site.xml, mapred-default.xml, mapred-site.xml, yarn-default.xml, yarn-site.xml, hdfs-default.xml, hdfs-site.xml, job.xml] under bean name 'hadoopConfiguration': there is already object [org.springframework.data.hadoop.configuration.Conf igurationFactoryBean@27b104d7] bound

    Comment


    • #3
      have you tried
      Code:
      public void removeBeanDefinition(String beanName) instead of destroyBean.

      Comment


      • #4
        i am using ClassPathXmlApplicationContext and it does not have this method.

        Comment

        Working...
        X