In an event you encounter an error as below in the development of a spring application with STS; you can find the solution as stated.

Error:

Exception in thread “main” org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 14 in XML document from class path resource [META-INF/spring/app-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: The prefix “p” for attribute “p:messageProvider-ref” associated with an element type “bean” is not bound.
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions
(XmlBeanDefinitionReader.java:396)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions
(XmlBeanDefinitionReader.java:334)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions
(XmlBeanDefinitionReader.java:302)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
(AbstractBeanDefinitionReader.java:143)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
(AbstractBeanDefinitionReader.java:178)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
(AbstractBeanDefinitionReader.java:149)
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions
(AbstractBeanDefinitionReader.java:212)
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions
(AbstractXmlApplicationContext.java:126)
org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions
(AbstractXmlApplicationContext.ja va:92)
org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory
(AbstractRefreshableApplicationContext.java:130)
org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory
(AbstractApplicationContext.java:467)
org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:397)
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
com.apress.prospring3.ch2.HelloWorldSpringDI.main(HelloWorldSpringDI.java:15)
Caused by: org.xml.sax.SAXParseException: The prefix “p” for attribute “p:messageProvider-ref” associated with an element type “bean” is not bound.
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError
(ErrorHandlerWrapper.java:174)
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:388)
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError
(XMLErrorReporter.java:318)
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement
(XMLNSDocumentScannerImpl.java:334)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next
(XMLDocumentFragmentScannerImpl.java:2755)
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next
(XMLDocumentScannerImpl.java:648)
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next
(XMLNSDocumentScannerImpl.java:140)
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument
(XMLDocumentFragmentScannerImpl.java:511)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
… 14 more

Solution:
To resolve this problem, the line below would have to be included in the xml schema definition in the first few lines of your xml file (in my case app-context.xml)
xmlns:p=”http://www.springframework.org/schema/p&#8221;

so i have the first 5 lines of my xml file to be this:
<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”http://www.springframework.org/schema/beans&#8221;
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;
xmlns:p=”http://www.springframework.org/schema/p&#8221;
xmlns:context=”http://www.springframework.org/schema/context&#8221;

*This works fine.

Advertisements

2 thoughts on “Spring Error

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s