Spring LDAP authenticate method throws java.lang.NoSuchMethodError
-
01-07-2021 - |
Pregunta
I am trying to use the LDAPTemplate authenticate
method from Spring LDAP (1.3.1.RELEASE), but it throws following exception
java.lang.NoSuchMethodError: org.springframework.ldap.core.LdapTemplate.authenticate(Ljavax/naming/Name;Ljava/lang/String;Ljava/lang/String;)Z
Following are my Maven 3.0.1 dependencies
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core-tiger</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-odm</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-ldif-core</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-ldif-batch</artifactId>
<version>1.3.1.RELEASE</version>
</dependency>
Following is the code I used to authenticate
AndFilter andFilter = new AndFilter();
andFilter.and(new EqualsFilter("objectclass", "person"));
andFilter.and(new EqualsFilter("uid", "myid"));
ldapTemplate.authenticate(DistinguishedName.EMPTY_PATH, andFilter.toString(), "password");
FYI... I have used other LDAPTemplate
methods like search
, bind
, unbind
without any problems.
Solución
LdapTemplate.authenticate is quite new.
You probably had an older version of the library cached by Maven (or your IDE), causing the runtime version being older than the one used for compilation.
Otros consejos
The error went away after restarting the server
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow