title: no declaration can be found for element 'mvc:annotation-driven'
body: <p>I have the requirement of returning JSON/XML data from my controller.From what i found,I needed <code>@ResponseBody</code> in my method and for that I need <code>&lt;mvc:annotation-driven&gt;</code> enabled. I have tried all sorts of RnD but am still stuck! :(</p>
  
  <p>Apparently my problem lies in my servlet.xml file (the schema isnt getting validated!)
  I am using Spring 3.1.1 &amp; have explicitly put in spring-mvc-3.1.1.jar in my classpath.</p>
  
  <p>Here's my servlet-context file sample-servlet.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"
         xmlns:mvc="http://www.springframework.org/schema/mvc"
         xsi:schemaLocation="http://www.springframework.org/schema/tx                      http://www.springframework.org/schema/tx/spring-tx.xsd
           http://www.springframework.org/schema/mvc-3.1  http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
           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"&gt;
  
  
    &lt;context:component-scan base-package="com.sample.controller"/&gt;
    &lt;mvc:annotation-driven/&gt;  
  
    &lt;!--Use JAXB OXM marshaller to marshall/unmarshall following class--&gt;
    &lt;bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /&gt;
  
    &lt;bean id="xmlViewer" 
          class="org.springframework.web.servlet.view.xml.MarshallingView"&gt;
      &lt;constructor-arg&gt;
        &lt;bean class="org.springframework.oxm.jaxb.Jaxb2Marshaller"&gt;
          &lt;property name="classesToBeBound"&gt;
            &lt;list&gt;
              &lt;value&gt;com.sample.model.SampleClass&lt;/value&gt;
            &lt;/list&gt;
          &lt;/property&gt;
        &lt;/bean&gt;
      &lt;/constructor-arg&gt;
    &lt;/bean&gt;
  
    &lt;bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver"&gt;
  
    &lt;property name="viewResolvers"&gt;
      &lt;list&gt;
        &lt;bean class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
          &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/&gt;
          &lt;property name="prefix" value="/WEB-INF/jsp/"/&gt;
          &lt;property name="suffix" value=".jsp"/&gt;
        &lt;/bean&gt;
      &lt;/list&gt;
    &lt;/property&gt;
  &lt;/bean&gt; 
  </code></pre>
  
  <p></p>
  
  <p>My controller class looks like this :</p>
  
  <pre><code>@Controller
  public class XmlController {
  
    @RequestMapping(value="/getXml",method = RequestMethod.POST)
    public @ResponseBody AssociateDetail getXml(){
      System.out.println("inside xml controller.....");
      AssociateDetail assoBean=null;
  
      try{
        AssociateService add=new AssociateService();
        assoBean=add.selectAssociateBean();
      }catch(Exception e){
        e.printStackTrace();
      }
  
      return assoBean;    
    }
  }
  </code></pre>
  
  <p>Now the problem is <code>&lt;mvc:annotation-driven /&gt;</code> gives error:</p>
  
  <blockquote>
    <p>cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driven'.</p>
  </blockquote>
  
  <p>And I have tried all the workarounds suggested on this site and beyond. Have updated my schema namespaces, using Spring 3.1.1 and <code>@ResponseBody</code>.</p>