Duplicate spring bean ID troubleshooting

Source: Internet
Author: User
Symptom

An error occurred while running the application task.

{code}Caused by: java.lang.IllegalStateException: Duplicate spring bean id realnameAuthPubService        at com.alibaba.dubbo.rpc.config.spring.schema.DubboBeanDefinitionParser.parse(DubboBeanDefinitionParser.java:87)        at com.alibaba.dubbo.rpc.config.spring.schema.DubboBeanDefinitionParser.parse(DubboBeanDefinitionParser.java:63)        at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297)        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92)        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398){code}
Troubleshooting

Check the Code. There is indeed a duplicate configuration with the ID realnameauthpubservice, but it has been around for a long time and has never been a problem before.

The problem occurred only when the Dubbo upgrade requirement was released on the day. Therefore, it was found that the Dubbo upgrade caused this persistent problem.

The cause of spring's default processing policy for ID duplication is overwriting, such as defaultlistablebeanfactory. registerbeandefinition. Dubbo did not perform special processing before, so duplicate IDs will be overwritten, so no error is reported.
{Code}... synchronized (this. beandefinitionmap) {object oldbeandefinition = This. beandefinitionmap. Get (beanname); If (oldbeandefinition! = NULL) {## allowbeandefinitionoverriding default value: tureif (! This. allowbeandefinitionoverriding) {Throw new beandefinitionstoreexception (beandefinition. getresourcedescription (), beanname, "cannot register bean Definition [" + beandefinition + "] for bean '" + beanname + "': there is already [" + oldbeandefinition + "] bound. ");} else {If (this. logger. isinfoenabled () {this.logger.info ("overriding bean definition for bean '" + beanname + "': replacing ["+ oldbeandefinition +"] with ["+ beandefinition +"] ") ;}} else {This. beandefinitionnames. add (beanname); this. frozenbeandefinitionnames = NULL ;}## overwrite this. beandefinitionmap. put (beanname, beandefinition );... {code}
The new version of Dubbo performs special processing on duplicate IDs. If there are duplicates, an exception is thrown directly, so an error occurs.
{Code} dubbobeandefinitionparser. parse private beandefinition parse (element, parsercontext, class <?> Beanclass, Boolean required) {... If (ID! = NULL & ID. length ()> 0) {### determine whether the existence exists. If (parsercontext. getregistry (). containsbeandefinition (ID) {Throw new illegalstateexception ("Duplicate spring bean ID" + id);} parsercontext. getregistry (). registerbeandefinition (ID, beandefinition );}...} {code}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.