16

I have added the spring-security-config-3.1.0.RC3.jar in my lib folder and i still get this error. What can be possible reason ??

Here is my dispatcher-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   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">

   <context:component-scan base-package="com.tcs.rspm.controller" />
<mvc:annotation-driven /> 
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/webpages/" />
      <property name="suffix" value=".jsp" />
   </bean>

</beans>
Abhishek Singh
  • 10,243
  • 22
  • 74
  • 108

2 Answers2

41

You have this:

xmlns:mvc="http://www.springframework.org/schema/mvc"

but you're not mentioning it here:

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">

To fix that, you should have

http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd

there as well, like

xsi:schemaLocation="
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
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">

Note: it is actually common that schema references don't mention Spring version to allow for easier upgrading, so you should use references like http://www.springframework.org/schema/context/spring-context.xsd instead of the ones having -3.0 in the name.

eis
  • 51,991
  • 13
  • 150
  • 199
  • I got similiar error for annotation. When I remove version part of schema urls the error in xml file (eclipse) disappears but tomcat can't start, giving the same error. Where can I check where is the mvc:cors and what should add in xmlns and schemaLocation? – Ismail Yavuz Jan 09 '19 at 13:01
  • I found that Spring 4.2 has the first support for CORS, version update solved my problem. – Ismail Yavuz Jan 09 '19 at 13:57
-1

I had an almost similar error as you. My applicationContext.xml file was like this :

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/beans/spring-beans.xsd">//should be context instead of beans

When I had tried to write

<context:property-placeholder location="file:src/application.properties"/>

then I got error.I fixed the error by copying the code which is below :

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">
ozgunsngr
  • 1
  • 1