在执行 answer.nextElement() 时,我在 jre 中有一个错误
java.lang.NullPointerException:在 com.sun.jndi.ldap.LdapNamingEnumeration.getNextBatch(LdapNamingEnumeration.java:111) ~[na:1.6.0_31] 在 com.sun.jndi.ldap.LdapNamingEnumeration.nextAux(LdapNamingEnumeration.java) 处为空:245) ~[na:1.6.0_31] at com.sun.jndi.ldap.LdapNamingEnumeration.nextImpl(LdapNamingEnumeration.java:236) ~[na:1.6.0_31] at com.sun.jndi.ldap.LdapNamingEnumeration.next (LdapNamingEnumeration.java:184) ~[na:1.6.0_31] at com.sun.jndi.ldap.LdapNamingEnumeration.nextElement(LdapNamingEnumeration.java:88) ~[na:1.6.0_31]
这是我的代码:
LdapContext ctx = ...;
NamingEnumeration<SearchResult> answer = ctx.search(...);
if (answer.hasMoreElements()) {
...
}
while (answer.hasMoreElements()) {
String grpName = answer.nextElement().getAttributes().get("xxx").get().toString();
...
}
我不知道去哪里调查。
最好的,