farrellmr
farrellmr

Reputation: 1905

Invalid property 'defaultCountLimit' of bean class [org.springframework.ldap.core.LdapTemplate]

Im getting the following exception while trying to configure the LDAPTemplate on Spring -

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapTemplate': Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'defaultCountLimit' of bean class [org.springframework.ldap.core.LdapTemplate]: Bean property 'defaultCountLimit' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

My configuration is -

<ldap:context-source 
        id="contextSource"
        url="myurl"
        base="mybase"
        username="myuser"
        password="mypassword"
        referral="follow"
/>

<ldap:ldap-template id="ldapTemplate" context-source-ref="contextSource" />

Ive checked the config and it is working fine when i dont work through the spring context -

    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrl("myurl");
    contextSource.setBase("mybase");
    contextSource.setUserDn("myuser");
    contextSource.setPassword("mypassword");
    contextSource.setReferral("follow");
    contextSource.afterPropertiesSet();

    LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
    ldapTemplate.afterPropertiesSet();

I cannot see where the countlimit is being set to cause this issue. Ive also tried top set the count limit through ldap-template.

Versions -

<dependency>
  <groupId>org.springframework.ldap</groupId>
  <artifactId>spring-ldap-core</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.ldap</groupId>
  <artifactId>spring-ldap</artifactId>
  <version>1.3.1.RELEASE</version>
  <classifier>all</classifier>
</dependency>

Upvotes: 0

Views: 373

Answers (1)

marthursson
marthursson

Reputation: 3300

This is probably due to a dependency version mismatch. Make sure that you only refer to the correct maven artefacts. For the basic case all you need is spring-ldap-core:

<dependency>
  <groupId>org.springframework.ldap</groupId>
  <artifactId>spring-ldap-core</artifactId>
  <version>2.0.4.RELEASE</version>
</dependency>

The spring-ldap dependency you listed is legacy and should not be included.

Upvotes: 1

Related Questions