Announcement Announcement Module
No announcement yet.
Spring and Security 3.1.0.RELEASE with LDAP 1.3.1.RELEASE - SecurityContextHolder Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring and Security 3.1.0.RELEASE with LDAP 1.3.1.RELEASE - SecurityContextHolder

    I tried to generate a new app using ROO and it configured the pom to use the latest and greatest versions. Unfortunately, the same bean definitions I am using in another project with older versions no longer works - when I try to run a main() method as a Java Application, I get the following error:

    Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/security/core/context/SecurityContextHolder
    	at org.springframework.ldap.authentication.DefaultValuesAuthenticationSourceDecorator.getPrincipal(
    	at org.springframework.ldap.core.LdapTemplate.executeReadOnly(
    	at org.springframework.ldap.core.LdapTemplate.lookup(
    	at org.springframework.ldap.core.simple.SimpleLdapTemplate.lookup(
    	at com.qualcomm.corp.isso.cis.ldap.dao.LdapDAOBase.findByPrimaryKey(
    	at com.qualcomm.corp.isso.cis.ldap.operations.GetPerson.invoke(
    	at com.qualcomm.corp.isso.cis.ldap.operations.GetPerson.main(
    Caused by: java.lang.ClassNotFoundException:
    Here are the versions I'm using in the POM:

    And here is the applicationContext-ldap.xml file that is being imported into my primary applicationContext.xml file:
    	<!-- -->
    	<!-- Basic DataSource -->
    	<bean id="contextSource" class=""
    	<bean id="authenticationSource" class="org.springframework.ldap.authentication.DefaultValuesAuthenticationSourceDecorator"
    	<bean id="springSecurityAuthenticationSource"
    		class="" />
    	<bean class="" />
    	<bean id="simpleLdapTemplate" class="org.springframework.ldap.core.simple.SimpleLdapTemplate">
    		<constructor-arg ref="contextSource" />
    For now I'm going to revert to the older versions so that I can get my application to run but I would love to know what is wrong with the configuration for the newer versions -- or is there a bug in the latest and greatest code?

    NOTE: I googled for this error and I saw that this can occur if the app is using another library which is compiled against Spring Security 2. The pom's Dependency Hierarchy does not indicate that any older versions are being used. It may also be useful to note that we are using spring-ldap-core-tiger in the app...

  • #2
    In general a ClassNotFoundException means that the class cannot be found on your classpath. Did you ensure to include spring-security-core in the classpath? If in the future you have trouble figuring out which jar contains the class you are missing try using You can use the advanced search to search by class name as shown by this query it would tell you which jar you were missing. Note this would work for any class in maven central.


    • #3
      You're awesome! That handled it! I only had spring-security-ldap which excluded spring-seciryt-core. sigh.