I am getting below error when running my application on apache tomcat.
HTTP Status 500 - Servlet.init() for servlet spring threw exception
root cause
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 11 in XML document from ServletContext resource [/WEB-INF/spring-servlet.xml] is invalid;
nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
My spring-context.xml is this
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cotext="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc">
<mvc:annotation-driven/>
<cotext:component-scan base-package="springmvc"/>
I’ve tried https://jira.springsource.org/browse/SPR-3372 with no luck.
please help.
Few things looks off to me:
1) You have to remove ” http://java.sun.com/xml/ns/javaee” in xmlns attribute. I think this is the main problem here. “xmlns” attribute can’t take multiple URIs according to spec:
http://www.w3schools.com/xml/xml_namespaces.asp
2) Some XML libraries don’t like the spaces in the beginning of XML file in front of (in particular Eclipse will complain)
3) xsi:schemaLocation value is missing location URI for mvc. It should probably look like this:
You can as well remove extra “beans” declaration as previous answer suggests, unless you really want to use “beans” namespace prefix for some reason.