title: Spring security error with AOP
body: <p>I want to delegate the security of my project in Spring Security, but when I add the dependencies to my POM and start the server I get an error that doesn't make sense... it says that my applicationContext.xml has an error and it points to the line where I have an aop sentence...</p>
  
  <p>Here is a reduced version of my applicationContext.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:util="http://www.springframework.org/schema/util"
          xmlns:context="http://www.springframework.org/schema/context"
          xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
          xsi:schemaLocation="  
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd  
          http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-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"&gt;
  
   &lt;!-- Activates scanning of @Autowired --&gt;
      &lt;context:annotation-config/&gt;
  
      &lt;!-- Activates scanning of @Repository and @Service --&gt;
      &lt;context:component-scan base-package="es.myproject"/&gt;
  
      &lt;!-- datasource configuration --&gt;
      &lt;context:property-placeholder location="classpath:jdbc.properties" /&gt;
  
      &lt;bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
          &lt;property name="jndiName" value="${jndi.name}" /&gt;
          &lt;property name="lookupOnStartup" value="true"&gt;&lt;/property&gt;
          &lt;property name="cache" value="true"&gt;&lt;/property&gt;
          &lt;property name="proxyInterface" value="javax.sql.DataSource"&gt;&lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;!-- hibernate session factory --&gt;
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt;
          &lt;property name="dataSource"  ref="dataSource" /&gt;
          &lt;property name="configLocation" value="classpath:hibernate.cfg.xml" /&gt;
          &lt;property name="packagesToScan" value="es.myproject.modelo.datos" /&gt;
      &lt;/bean&gt;
  
      &lt;!-- enable the configuration of transactional behavior based on annotations --&gt;
      &lt;aop:aspectj-autoproxy /&gt;
      &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
  
      &lt;!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) --&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>These are de dependencies:</p>
  
  <pre><code>&lt;!-- Spring security --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-core&lt;/artifactId&gt;
              &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;    
  
          &lt;/dependency&gt; 
         &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-web&lt;/artifactId&gt;
              &lt;version&gt;3.1.0.RELEASE&lt;/version&gt; 
          &lt;/dependency&gt;   
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;
              &lt;artifactId&gt;spring-security-config&lt;/artifactId&gt;
              &lt;version&gt;3.1.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>And the error points to <code>&lt;aop:aspectj-autoproxy /&gt;</code> in the applicationContext.xml</p>
  
  <p>If I delete the Spring Security dependencies, the error goes away... weird huh? Any ideas anybody?</p>
  
  <p>The error says:
  <code>org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/aop/spring-aop-3.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not &lt;xsd:schema&gt;.
  org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 41 in XML document from ServletContext resource [/WEB-INF/classes/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:aspectj-autoproxy'.</code></p>
  
  <p>But there's no real problem with reading that xsd, as I said if I delete the spring security dependencies this error doesn't show... </p>