Hi,
I am a newbie to Spring framework. As part of the project, I need to perform Ldap authentication for the user. I followed the documentation and created the following...
the beans using this are below:Code:<bean id="contextSource" class="org.springframework.ldap.core.support.LdapContextSource"> <property name="url" value="ldap://xxx.xxx.xxx:xxx" /> <property name="base" value="ou=active,ou=employees,ou=people,o=xxxxxxx.com" /> <property name="authenticationSource" ref="springSecurityAuthenticationSource" /> </bean> <bean id="springSecurityAuthenticationSource" class="org.springframework.security.ldap.authentication.SpringSecurityAuthenticationSource" /> <bean id="ldapBean" class="com.learn.authz.AuthorizeUser"> <property name="contextSource" ref="contextSource"></property> </bean>
This fails when I load the beans using ClassPathXMLApplicationContext.Code:import org.springframework.ldap.core.ContextSource; import org.springframework.ldap.core.LdapTemplate; public class AuthorizeUser implements UserAuthentication { private LdapTemplate ldapTemplate; public void setContextSource(ContextSource contextSource) throws Exception { // TODO Auto-generated method stub this.ldapTemplate = new LdapTemplate(contextSource); } public boolean isAuthenticated(String username, String password) throws Exception { boolean val = ldapTemplate.authenticate("", "(uid=" + username + ")",password); return val; } }
I get the following error:
Am I missing any parameters in the xml configuration file?Code:Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'contextSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/dao/EmptyResultDataAccessException at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102) at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1350) ... 13 more
Appreciate any pointers towards this.
Thanks,
Rishikesh R.


Reply With Quote