Spring LDAP authenticate方法抛出java.lang.NoSuchMethodError

时间:2012-09-11 17:48:41

标签: spring spring-ldap

我正在尝试使用Spring LDAP(1.3.1.RELEASE)中的LDAPTemplate authenticate方法,但它会抛出异常

java.lang.NoSuchMethodError: org.springframework.ldap.core.LdapTemplate.authenticate(Ljavax/naming/Name;Ljava/lang/String;Ljava/lang/String;)Z

以下是我的Maven 3.0.1依赖项

<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>

以下是我用于验证的代码

    AndFilter andFilter = new AndFilter();
    andFilter.and(new EqualsFilter("objectclass", "person"));
    andFilter.and(new EqualsFilter("uid", "myid"));
    ldapTemplate.authenticate(DistinguishedName.EMPTY_PATH, andFilter.toString(), "password");

仅供参考我...我使用了其他LDAPTemplate方法,例如searchbindunbind,没有任何问题。

2 个答案:

答案 0 :(得分:0)

重启服务器后错误消失

答案 1 :(得分:0)

LdapTemplate.authenticate很新。

您可能拥有Maven(或您的IDE)缓存的旧版本库,导致运行时版本比用于编译的版本旧。