user978758
user978758

Reputation: 599

no declaration can be found for 'mvc:annotation-driven'

I have got simple web app (spring 3 + thymeleaf, deploy on glassfish 3.x). When I try run it there is an error:

SEVERE: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 16 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 24; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.

here is my applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
   http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
   http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/context/spring-mvc-3.1.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
          <context:component-scan base-package="arek" />
         <mvc:annotation-driven></mvc:annotation-driven>
   </beans>

I searched but nothing. Thanks for help.

Upvotes: 0

Views: 4349

Answers (2)

VHS
VHS

Reputation: 10184

The spring MVC schema file that you are trying to reference in your application context (http://www.springframework.org/schema/context/spring-mvc-3.1.xsd) doesn't exist. Open this link yourself in a browser and you will see 404 error. The latest MVC schema file location is (http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd). Use this and you won't get the exception.

Upvotes: 0

Shinichi Kai
Shinichi Kai

Reputation: 4513

Try http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd instead of http://www.springframework.org/schema/context/spring-mvc-3.1.xsd .

Hope this helps.

Upvotes: 3

Related Questions