Org. springframework. Beans. Factory. beandefinitionstoreexception:

Source: Internet
Author: User

Exception in thread "Main" org. springframework. beans. factory. beandefinitionstoreexception: Line 5 in XML document from class path resource [applicationcontext. XML] is invalid; Nested exception is Org. XML. sax. saxparseexception: document root element "beans", must match doctype root "null ". <br/> Org. XML. sax. saxparseexception: document root element "beans", must match doctype root "null ". <br/> at Org. apache. xerces. util. errorhandlerwrapper. createsaxparseexception (unknown source) <br/> at Org. apache. xerces. util. errorhandlerwrapper. error (unknown source) <br/> at Org. apache. xerces. impl. xmlerrorreporter. reporterror (unknown source) <br/> at Org. apache. xerces. impl. xmlerrorreporter. reporterror (unknown source) <br/> at Org. apache. xerces. impl. DTD. xmldtdvalidator. rootelementspecified (unknown source) <br/> at Org. apache. xerces. impl. DTD. xmldtdvalidator. handlestartelement (unknown source) <br/> at Org. apache. xerces. impl. DTD. xmldtdvalidator. startelement (unknown source) <br/> at Org. apache. xerces. impl. xmldocumentfragmentscannerimpl. scanstartelement (unknown source) <br/> at Org. apache. xerces. impl. xmldocumentscannerimpl $ contentdispatcher. scanrootelementhook (unknown source) <br/> at Org. apache. xerces. impl. xmldocumentfragmentscannerimpl $ fragmentcontentdispatcher. dispatch (unknown source) <br/> at Org. apache. xerces. impl. xmldocumentfragmentscannerimpl. scandocument (unknown source) <br/> at Org. apache. xerces. parsers. xml11configuration. parse (unknown source) <br/> at Org. apache. xerces. parsers. xml11configuration. parse (unknown source) <br/> at Org. apache. xerces. parsers. xmlparser. parse (unknown source) <br/> at Org. apache. xerces. parsers. domparser. parse (unknown source) <br/> at Org. apache. xerces. JAXP. documentbuilderimpl. parse (unknown source) <br/> at Org. springframework. beans. factory. XML. xmlbeandefinitionreader. doloadbeandefinitions (xmlbeandefinitionreader. java: 222) <br/> at Org. springframework. beans. factory. XML. xmlbeandefinitionreader. loadbeandefinitions (xmlbeandefinitionreader. java: 173) <br/> at Org. springframework. beans. factory. XML. xmlbeandefinitionreader. loadbeandefinitions (xmlbeandefinitionreader. java: 148) <br/> at Org. springframework. beans. factory. support. abstractbeandefinitionreader. loadbeandefinitions (abstractbeandefinitionreader. java: 128) <br/> at Org. springframework. beans. factory. support. abstractbeandefinitionreader. loadbeandefinitions (abstractbeandefinitionreader. java: 144) <br/> at Org. springframework. context. support. abstractxmlapplicationcontext. loadbeandefinitions (abstractxmlapplicationcontext. java: 113) <br/> at Org. springframework. context. support. abstractxmlapplicationcontext. loadbeandefinitions (abstractxmlapplicationcontext. java: 81) <br/> at Org. springframework. context. support. abstractrefreshableapplicationcontext. refreshbeanfactory (abstractrefreshableapplicationcontext. java: 89) <br/> at Org. springframework. context. support. abstractapplicationcontext. refresh (abstractapplicationcontext. java: 262) <br/> at Org. springframework. context. support. classpathxmlapplicationcontext. <init> (classpathxmlapplicationcontext. java: 87) <br/> at Org. springframework. context. support. classpathxmlapplicationcontext. <init> (classpathxmlapplicationcontext. java: 72) <br/> at Org. springframework. context. support. classpathxmlapplicationcontext. <init> (classpathxmlapplicationcontext. java: 63) <br/> at Org. xmh. test. testhiberante2.main (testhiberante2.java: 11)

 

Beans. Factory. beandefinitionstoreexception is caused by beans. Factory. So what is it? In the spring configuration file, that is, the configuration file beans you want to load, the object found is empty,

Common Errors:

Inconsistent spring versions, such as spring2.0 and 3.0

Example:

When xfire is added to spring2.0 (myeclipse), the following error occurs:
Document root element "beans", must match doctype root "null ".
Cause: spring1.2.6 conflicts with spring 2 in xfire core Lib!

<? XML version = "1.0" encoding = "UTF-8"?>
<Beans xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation = "http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans-2.0.xsd>
</Beans>

Spring 1.x uses doctype, while 2.x uses schema
Xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation = "http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans-2.0.xsd>
Delete, change
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype beans public "-// spring // DTD bean // en" "http://www.springframework.org/dtd/spring-beans.dtd">
<Beans> </beans>

We often need to select a version when adding spring support to myeclipse. Later, we used spring web projects in the eclipse tool and didn't want to install myeclipse. This problem was encountered, but it was not very difficult.

 

Continue to practice. Use eclipse to learn things and install the required plug-ins. I think the learning is clearer and the entire process is clearer. I suggest you.

Of course, myeclipse is used for comparison. If there are ready-made tools, you can use them directly!

 

 

 

 

 

 

 

 

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.