Subhranil Sengupta
Subhranil Sengupta

Reputation: 119

Error: cvc-elt.1: Cannot find the declaration of element 'beans'

I cannot get rid of this error:

cvc-elt.1: Cannot find the declaration of element 'beans'.

I am running my web project on Tomcat 9. I have tried all the ways mentioned on stackoverflow, still unable to deal with it. I guess it has something to do with the Spring 5.

Here is my code:

<?xml version="1.0" encoding="UTF-8"?>
<beans  xmlns="http://www.springframework.org/schema/beans"
        xmlns:beans="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        ">

        <bean id="HandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
        <bean name="/welcome.html" class="com.gontuseries.hellocontroller.HelloController"/>
        <bean id="ViewResolver"
              class="org.springframework.web.servlet.view.InternalResourceViewResolver">
              <property name="prefix">
                <value>/WEB-INF/</value>
              </property>       
                <property name="suffix">
                <value>.jsp</value>
              </property>   
        </bean> 
</beans>

and below is the exception I am getting:

Sep 25, 2018 1:15:46 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Allocate exception for servlet [spring-dispatcher]
org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 6; cvc-elt.1: Cannot find the declaration of element '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)

Upvotes: 1

Views: 1962

Answers (1)

kjhughes
kjhughes

Reputation: 111726

Change

    xmlns:schemaLocation="

to

    xsi:schemaLocation="

See also xmlns, xmlns:xsi, xsi:schemaLocation, and targetNamespace?

Upvotes: 1

Related Questions