title: Spring Security 3.1 And The Right Jars
body: <p>I'm using Spring 3.1 and I am doing LDAP for the first time.</p>
  
  <p>Here is my *-security.xml:</p>
  
  <pre><code>&lt;beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/security
      http://www.springframework.org/schema/security/spring-security-3.1.xsd"&gt;
  
    &lt;http auto-config="true"&gt;
      &lt;intercept-url pattern="/welcome*" access="ROLE_USER" /&gt;
      &lt;form-login login-page="/login" default-target-url="/welcome"
        authentication-failure-url="/loginfailed" /&gt;
      &lt;logout logout-success-url="/logout" /&gt;
    &lt;/http&gt;
  
    &lt;ldap-server url = "ldap://ldap-east.abc.acme.org:636/o=acme.org" /&gt;
  
      &lt;authentication-manager&gt;
        &lt;ldap-authentication-provider user-dn-pattern="uid={0},ou=people"/&gt;
      &lt;/authentication-manager&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>I started with these security related jars in my lib:</p>
  
  <pre><code>spring-security-ldap-3.1.0.RELEASE.jar
  spring-security-config-3.1.0.RELEASE.jar
  spring-security-core-3.1.0.RELEASE.jar
  spring-security-taglibs-3.1.0.RELEASE.jar
  spring-security-web-3.1.0.RELEASE.jar
  </code></pre>
  
  <p>And I got this error message:</p>
  
  <blockquote>
    <p>org.springframework.context.ApplicationContextException: 
        Couldn't locate: org.springframework.ldap.core.support.BaseLdapPathContextSource.<br>
        If you are using LDAP with Spring Security, 
        please ensure that you include the spring-ldap jar file in your application; 
        nested exception is java.lang.ClassNotFoundException: 
        org.springframework.ldap.core.support.BaseLdapPathContextSource</p>
  </blockquote>
  
  <p>So, I added more jars to lib to be this set of security files:</p>
  
  <pre><code>spring-ldap-core-1.3.1.RELEASE.jar
  spring-ldap-core-tiger-1.3.1.RELEASE.jar
  spring-security-ldap-3.1.0.RELEASE.jar
  spring-security-config-3.1.0.RELEASE.jar
  spring-security-core-3.1.0.RELEASE.jar
  spring-security-taglibs-3.1.0.RELEASE.jar
  spring-security-web-3.1.0.RELEASE.jar
  </code></pre>
  
  <p>That got me in deeper with even MORE error messages:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'org.springframework.security.filterChains': 
  Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' 
  while setting bean property 'sourceList' with key [0]; 
  nested exception is org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': 
  Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' 
  while setting constructor argument with key [2]; 
  nested exception is org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0':
  Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' w
  hile setting bean property 'authenticationManager'; 
  nested exception is org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'org.springframework.security.authentication.ProviderManager#0': 
  Cannot resolve reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' 
  while setting constructor argument; nested exception is 
  org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': 
  FactoryBean threw exception on object creation; nested exception is org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'org.springframework.security.authenticationManager': 
  Cannot resolve reference to bean 'org.springframework.security.ldap.authentication.LdapAuthenticationProvider#0' 
  while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'org.springframework.security.ldap.authentication.LdapAuthenticationProvider#0': 
  Cannot create inner bean '(inner bean)' of type [org.springframework.security.ldap.authentication.BindAuthenticator] 
  while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name '(inner bean)#17': Cannot resolve reference to bean 'org.springframework.security.securityContextSource' 
  while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: 
  Error creating bean with name 'org.springframework.security.securityContextSource': 
  Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
  Could not instantiate bean class [org.springframework.security.ldap.DefaultSpringSecurityContextSource]: 
  Constructor threw exception; nested exception is java.lang.NoClassDefFoundE
  </code></pre>
  
  <p>I'm catching up on a lot of things, learning Maven is on my list, but I am not there yet.  Any tips on getting the right mix jars to do a basic LDAP authentication with Spring 3.1?</p>
  
  <p><strong>I tried loading the entire Spring 3.1.1 dist, the entire Spring LDAP 1.3.1 dist and the entire Spring Security 3.1.0 dist.   I've got everything.  So I am at a loss to see how this is a dependency issue, FWIW.</strong></p>