caused by:org.xml.sax.SAXParseException; Linenumber:7; columnnumber:72; You must declare the attribute for the element type "beans" xml_spring

Source: Internet
Author: User
Tags log4j

Error Tip:

Log4j:warn No Appenders could to found for logger (org.springframework.context.support.ClassPathXmlApplicationContext) .
Log4j:warn Please initialize the log4j system properly.
Exception in thread ' main ' org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:Line 7 in XML Document from class path resource [Applicationcontext.xml] is invalid; Nested exception is org.xml.sax.SAXParseException; Linenumber:7; columnnumber:72; Attribute ' xmlns ' must be declared for the element type ' beans '.
caused by:org.xml.sax.SAXParseException; Linenumber:7; columnnumber:72; Attribute ' xmlns ' must be declared for the element type ' beans '.
At Com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException (Unknown Source)
At Com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleStartElement (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$contentdriver.scanrootelementhook (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.xmldocumentfragmentscannerimpl$fragmentcontentdriver.next (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.xmldocumentscannerimpl$prologdriver.next (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next (Unknown Source)
At Com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument (Unknown Source)
At Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (Unknown Source)
At Com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse (Unknown Source)
At Com.sun.org.apache.xerces.internal.parsers.XMLParser.parse (Unknown Source)
At Com.sun.org.apache.xerces.internal.parsers.DOMParser.parse (Unknown Source)
At Com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse (Unknown Source)
At Org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument (defaultdocumentloader.java:73)
At Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions ( xmlbeandefinitionreader.java:361)
At Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions ( xmlbeandefinitionreader.java:313)
At Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions ( xmlbeandefinitionreader.java:290)
At Org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions ( abstractbeandefinitionreader.java:131)
At Org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions ( abstractbeandefinitionreader.java:147)
At Org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions ( abstractbeandefinitionreader.java:173)
At Org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions ( abstractxmlapplicationcontext.java:112)
At Org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions ( abstractxmlapplicationcontext.java:79)
At Org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory ( ABSTRACTREFRESHABLEAPPLICATIONCONTEXT.JAVA:101)
At Org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory ( abstractapplicationcontext.java:394)
At Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:324)
At Org.springframework.context.support.classpathxmlapplicationcontext.<init> ( classpathxmlapplicationcontext.java:122)
At Org.springframework.context.support.classpathxmlapplicationcontext.<init> ( CLASSPATHXMLAPPLICATIONCONTEXT.JAVA:66)
At Test.main (test.java:9)



Applicationcontext.xml contents are as follows:

<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE beans Public "-//spring//dtd BEAN 2.0//en" "Http://www.springframework.org/dtd/spring-beans-2.0.dtd" >


<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 ">
<!--establish target object instance-->
<bean id= "Hello" class= "Hello"/>
<!--Establish advice instance-->
<bean id= "SBA" class= "Saybeforeadvice"/>
<!--set up proxy objects-->
<bean id= "Helloproxy" class= "Org.springframework.aop.framework.ProxyFactoryBean" >
<!--set Agent interface-->
<property name= "Proxyinterfaces" >
<value>IHello</value>
</property>
<!--set the target object instance-->
<property name= "Target" >
<ref bean= "Hello"/>
</property>
<!--set Advice instance-->
<property name= "Interceptornames" >
<list>
<value>sba</value>
</list>
</property>
</bean>
</beans>


Workaround: Applicationcontext.xml The code in the red part of the <! DOCTYPE beans Public "-//spring//dtd BEAN 2.0//en" "Http://www.springframework.org/dtd/spring-beans-2.0.dtd" > Delete it off.

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.