PDA

View Full Version : constructor issues for LdapAuthenticationProvider.



farrellr
Oct 12th, 2006, 03:45 PM
I'm trying various ways to integrate acegi security with spring-ws.
I've managed to use plain text and hashed password with memory and dao.

Now I'm trying to work on Ldap. Since LdapAuthenticationProvider is a provider (rather than a userDetailsService) I'm only trying to get it work with plain text passwords.

I declare ldapAuthProvider in my applicationContext.xml as follows:


<bean id="ldapAuthProvider" class="org.acegisecurity.providers.ldap.LdapAuthenticatio nProvider" >
<constructor-arg index="0">
<bean class="org.acegisecurity.providers.ldap.authenticator.Bin dAuthenticator">
<constructor-arg><ref local="initialDirContextFactory" />
</constructor-arg>
<property name="userSearch" ref="userSearch" />
</bean>
</constructor-arg>
<constructor-arg index="1">
<bean class="org.acegisecurity.providers.ldap.populator.Default LdapAuthoritiesPopulator">
<constructor-arg>
<ref local="initialDirContextFactory" />
</constructor-arg>
<constructor-arg>
<value>CN=Groups,DC=utdtest,DC=com</value>
</constructor-arg>
<property name="groupRoleAttribute">
<value>cn</value></property>
</bean>
</constructor-arg>
</bean>


which has 2 constructor arguments, and the constuctor from the java looks like this:


public LdapAuthenticationProvider(LdapAuthenticator authenticator,
LdapAuthoritiesPopulator authoritiesPopulator) {
this.setAuthenticator(authenticator);
this.setAuthoritiesPopulator(authoritiesPopulator) ;
}


So it seems that bean instantiation should work, however I get the error:
...
Caused by:
org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.acegisecurity.providers.ldap.LdapAuthenticatio nProvider]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.acegisecurity.providers.ldap.LdapAuthenticatio nProvider.<init>()
Caused by:
java.lang.NoSuchMethodException: org.acegisecurity.providers.ldap.LdapAuthenticatio nProvider.<init>()
at java.lang.Class.getConstructor0(Class.java:2647)
at java.lang.Class.getDeclaredConstructor(Class.java: 1953)
at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:148)
...

any idea why? I'm not sure if this is an acegi issue, spring-ws, or something I'm doing wrong - any advice?

I'm posting this to both the acegi and spring-ws forums.
Thanks for any help.

farrellr
Oct 12th, 2006, 04:31 PM
My problem was I had another bean declared with no arguments (even though I wasn't using it for anything, of course spring was trying to create it).
Sorry for the post.