Results 1 to 4 of 4

Thread: Overriding singleton bean

  1. #1

    Default 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. #2

    Default

    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

  3. #3

    Default

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

  4. #4

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •