Unable to find declaration of 'beans' element in spring mvc portlet

161 Views Asked by At

We have created a Spring mvc portlet with given application context file:

<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context.xsd">
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="contentType" value="text/html;charset=UTF-8" />
        <property name="prefix" value="/WEB-INF/" />
        <property name="suffix" value=".jsp" />
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
    </bean>
</beans>

On deploying the portlet,the below error message is thrown:

Caused by: org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 64; cvc-elt.1: Cannot find the declaration of element 'beans'. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327) at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)

Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 6 in XML document from PortletContext resource [/WEB-INF/spring/portletpreferences-portlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 64; cvc-elt.1: Cannot find the declaration of element 'beans'.

The respective spring jars are available to the project as dependencies as shown below: enter image description here

I have referred all available similar questions to this issue and tried the following:

  1. Adding doctype tag
  2. Removing xsd version
  3. Using an empty elements with beans tag

Are there still any missing dependecies or errors in xml in context xml file.

Update: I have updated both spring beans and spring context jars to same version and also successfullly validated the xml file with xsd definition,but am still getting the same error post deployment.

0

There are 0 best solutions below