title: "ehcache: annotation-driven" definition cannot be found in my Spring context file
body: <p>I have an application using Spring and Ehcache. Each time I start the application from Eclipse, it runs fine. But when I build it from Maven and run it on the server, I keep having this error:</p>
  
  <pre><code>    INFO  XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring.xml]
      Exception in thread "main"     org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 29 in XML document from class path
  resource [spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 29; columnNumber: 71; cvc-complex-type.2.
  4.c: The matching wildcard is strict, but no declaration can be found for element 'ehcache:annotation-driven'.
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187)
          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:251)
          at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
          at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
          at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
          at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:540)
          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:454)
          at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
          at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:93)
          at com.natixis.etp.data.rmi.DataServer.main_aroundBody0(DataServer.java:145)
          at com.natixis.etp.data.rmi.DataServer.main(DataServer.java:45)
  Caused by: org.xml.sax.SAXParseException; lineNumber: 29; columnNumber: 71; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ehcache:annotation-driven'.
          at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
          at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
          at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:428)
          at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
  </code></pre>
  
  <p>The <code>ehcache:annotation-driven</code> definition exists in ehcache-spring-1.2.xsd.<br>
  I have read the several related issues about it, I applied what was adviced and so far I have no luck. I don't and can't use the Maven shader plugin because of our environment specifics, and I don't think it would help because I checked and rechecked the schema handlers in the dependencies.</p>
  
  <p>I wanted to know if you have any clue. Here is my spring file:</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:tx="http://www.springframework.org/schema/tx" 
              xmlns:aop="http://www.springframework.org/schema/aop"
              xmlns:ehcache="http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring"
              xsi:schemaLocation="
              http://www.springframework.org/schema/beans 
              http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
              classpath:spring-beans-3.0.xsd 
              http://www.springframework.org/schema/aop 
              http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
              classpath:spring-aop-3.0.xsd
              http://www.springframework.org/schema/context 
              http://www.springframework.org/schema/context/spring-context-3.2.xsd
              classpath:spring-context.xsd
              http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring
              http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.2.xsd
              classpath:ehcache-spring-1.2.xsd
              "&gt;
  
              &lt;context:annotation-config /&gt;
              &lt;context:spring-configured /&gt;
  
              [...]
  
              &lt;ehcache:annotation-driven mode="aspectj"
                  cache-manager="cacheManager" self-populating-cache-scope="shared" /&gt;
  
              &lt;aop:aspectj-autoproxy&gt;
                  &lt;aop:include name="traceInvocation" /&gt;
                  &lt;!-- aop:include name="performanceMonitor" / --&gt;
                  &lt;aop:include name="ehCacheInvocation" /&gt;
              &lt;/aop:aspectj-autoproxy&gt;
  
              &lt;ehcache:config cache-manager="cacheManager"&gt;
                  &lt;ehcache:evict-expired-elements
                      interval="60" /&gt;
              &lt;/ehcache:config&gt;
  
              &lt;bean id="cacheManager"
                  class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"&gt;
                  &lt;property name="configLocation" value="META-INF/ehcache.xml" /&gt;
                  &lt;property name="shared" value="true" /&gt;
              &lt;/bean&gt;
              [...]
          &lt;/beans&gt; 
  </code></pre>
  
  <p>As you see, I added the classpath entries because I had conflicts with schema handlers within the Spring aop schema handler.
  I have checked the content of <code>ehcache-aspectj-annotations-1.2.0.jar.dir/META-INF/spring.schemas</code>:</p>
  
  <pre><code>http\://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.0.xsd=com/googlecode/ehcache/annotations/ehcache-spring-1.0.xsd
  http\://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.1.xsd=com/googlecode/ehcache/annotations/ehcache-spring-1.1.xsd
  http\://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcache-spring-1.2.xsd=com/googlecode/ehcache/annotations/ehcache-spring-1.2.xsd
  </code></pre>
  
  <p>It seems fine to me.</p>
  
  <p>Here are my main dependencies by the way:</p>
  
  <pre><code>    &lt;dependencies&gt;
      [...]
          &lt;dependency&gt;
              &lt;groupId&gt;aopalliance&lt;/groupId&gt;
              &lt;artifactId&gt;aopalliance&lt;/artifactId&gt;
              &lt;version&gt;1.0&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;xerces&lt;/groupId&gt;
              &lt;artifactId&gt;xercesImpl&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework&lt;/groupId&gt;
              &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;net.sf.ehcache&lt;/groupId&gt;
              &lt;artifactId&gt;ehcache-core&lt;/artifactId&gt;
              &lt;version&gt;2.4.1&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;**************&lt;/groupId&gt;
              &lt;artifactId&gt;ehcache-aspectj-annotations&lt;/artifactId&gt;
              &lt;version&gt;1.2.0&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
              &lt;artifactId&gt;aspectjrt&lt;/artifactId&gt;
              &lt;version&gt;${aspectj.version}&lt;/version&gt;
              &lt;scope&gt;compile&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.aspectj&lt;/groupId&gt;
              &lt;artifactId&gt;aspectjweaver&lt;/artifactId&gt;
              &lt;version&gt;${aspectj.version}&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
            &lt;groupId&gt;com.googlecode.ehcache-spring-annotations&lt;/groupId&gt;
            &lt;artifactId&gt;ehcache-spring-annotations&lt;/artifactId&gt;
            &lt;version&gt;1.2.0&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  </code></pre>