Monday, April 13, 2015

How to resolve "A schema cannot contain two global components with the same name"?

When I have a project using spring-data-cassandra, the XML configuration applicationContext.xml's header looks like below.


...

Eclipse always complains the following errors:

Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans.xsd).  For more information, right click on the message in the Problems View and select "Show Details..."
Referenced file contains errors (http://www.springframework.org/schema/tool/spring-tool.xsd).  For more information, right click on the message in the Problems View and select "Show Details..."

The details are shown as below.

The errors below were detected when validating the file "spring-beans.xsd" via the file "applicationContext.xml".  In most cases these errors can be detected by validating "spring-beans.xsd" directly.  However it is possible that errors will only occur when spring-beans.xsd is validated in the context of applicationContext.xml.

sch-props-correct.2: A schema cannot contain two global components with the same name; this schema contains two occurrences of 'http://www.springframwork.org/schema/beans,identifiedType'. line 43
...

The problem is caused, I believe, by the version in different XSDs. For example, spring-context.xsd imports spring-beans.xsd and spring-tools.xsd, and always uses the links with a version like this: http://www.springframework.org/schema/beans/spring-beans-4.1.xsd.




...

But spring-cassandra.xsd imports XSDs without version.




 
...

If you download the following xsd, spring-beans, spring-tool, spring-cassandra, spring-context and spring-repository, and change all schemaLocations to point a local file like "file:///tmp/spring-beans.xsd", the validation errors will be gone.

This is really annoying when you see red X. Here are my suggestions:

  • remove xsi:schemaLocation in your applicationContext.xml, there will be a warning like "No grammar"
  • Window->Preferences->XML->XMl Files->Validation->uncheck "Honor all XML schema locations"

26 comments:

  1. this was an annoying error for me as well - thanks for providing this fix!

    ReplyDelete
  2. Hi admin thanks for sharing informative article on hadoop technology. In coming years, hadoop and big data handling is going to be future of computing world. This field offer huge career prospects for talented professionals. Thus, taking Hadoop & Spark Training in Hyderabad will help you to enter big data hadoop & spark technology.

    ReplyDelete
  3. Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.

    Cassandra Training Courses


    ReplyDelete
  4. i cant say how much i am thankful for you.

    ReplyDelete

  5. I am facing the same situation but in my case there is not hibernate-context.xml. Could you give some details about how did you debug the problem ? Selenium Training in Bangalore

    Python Training in Bangalore

    ReplyDelete
  6. Technology is new tool in all service sectors. I am working in health care sector with Top Hospitals in Hyderabad but I am very much interested in technology and its developments.

    ReplyDelete
  7. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info.
    Informatica Training in Chennai
    Python Training in Chennai
    Best AngularJS Training in Chennai

    ReplyDelete
  8. Thanks for sharing. i really appreciate it that you shared with us such a informative post.. Orthopedic Hospital in Hyderabad

    ReplyDelete
  9. You have done very well its really helpful post for skinny head . if you are not satisfy to other .you can check this link and get your dental treatments. Bariatric Surgery in Hyderabad

    ReplyDelete
  10. I have read some excellent stuff here. Certainly worth bookmarking for revisiting. I wonder how so much attempt you place to make this type of fantastic informative web site. Orthopedic Surgeon in Hyderabad

    ReplyDelete
  11. Thanks for the informative article. This is one of the best resources I have found in quite some time. Nicely written and great info. I really cannot thank you enough for sharing.
    python training in omr

    python training in annanagar | python training in chennai

    python training in marathahalli | python training in btm layout

    python training in rajaji nagar | python training in jayanagar

    ReplyDelete
  12. Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this. 
    python training in annanagar
    python training in chennai
    python training in chennai
    python training in Bangalore

    ReplyDelete
  13. Thanks you for sharing this unique useful information content with us. Really awesome work. keep on blogging
    DevOps online Training

    ReplyDelete
  14. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.

    iOS Training in Chennai
    Android Training in Chennai
    Mobile Apps Training in Chennai

    ReplyDelete
  15. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.

    angularjs Training in chennai
    angularjs Training in chennai

    angularjs-Training in tambaram

    angularjs-Training in sholinganallur

    angularjs-Training in velachery

    ReplyDelete
  16. Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
    AWS Training in Bangalore |Best AWS Training Institute in Bangalore BTM, Marathahalli
    AWS Training in Chennai | AWS Training Institute in Chennai Velachery, Tambaram, OMR

    ReplyDelete