【发布时间】:2019-05-10 18:48:45
【问题描述】:
我有问题尝试使用带有并行性的 spring-ldap 搜索在 LDAP 上搜索组。
我正在进行批处理以将数据从 SQL 数据库加载到 LDAP。我使用 spring-boot 和 spring-ldap。
我的算法尝试使用其 gidNumber 在 ldap 搜索组。在没有并行性(stream.parallelStream)的情况下运行时效果很好。但是当我用 parallelStream 迭代一个列表时,我有时会遇到这个异常:
java.lang.ClassCastException: class com.sun.jndi.ldap.LdapCtx cannot be cast to class org.springframework.ldap.core.DirContextAdapter (com.sun.jndi.ldap.LdapCtx is in module java.naming of loader 'bootstrap'; org.springframework.ldap.core.DirContextAdapter is in unnamed module of loader java.net.URLClassLoader @4f0f76b4)
我已将对象从 ContextMapper#mapFromContext 转换为 DirContextAdapter。 Spring-ldap 参考说,如果我不更改 DirObjectFactory LdapContextSource,此方法应返回 DirContextAdapter 的实例。
我的代码类似于:
ldapTemplate.search(
query().base(groupName()).where("gidNumber").is(Long.toString(gid)),
(ContextMapper<GroupLdap>) ctx -> {
DirContextAdapter context = (DirContextAdapter) ctx;
return new GroupLdap(context, true);
})
我的应用程序是将数据从 SQL 数据库加载到 LDAP 的批处理。我使用 spring-boot 和 spring-ldap。
我正在使用 spring-boot 2.1.4、OpenLdap 和 ORACLE 到 SQL-DB。和 open-jdk-zulu 11.
我的算法尝试使用其 gidNumber 在 ldap 搜索组。在没有并行性(stream.parallelStream)的情况下运行时效果很好。但是,当我使用 parallelStream() 迭代列表时,有时会遇到 ClassCastException:
我设置了一个 ldap 池连接,但它不起作用。
我的代码类似于:
ldapTemplate.search(
query().base(groupName()).where("gidNumber").is(Long.toString(gid)),
(ContextMapper<GroupLdap>) ctx -> {
DirContextAdapter context = (DirContextAdapter) ctx;
return new GroupLdap(context, true);
})
groupName 是引用“ou=groups,dc=fff,dc=br”的名称;
gid 是一个带有 gitNumber 搜索组的数字。
GroupLdap 是 LDAP 上组的内部表示。
使用并行性,我有时会收到异常:
java.lang.ClassCastException: class com.sun.jndi.ldap.LdapCtx cannot be cast to class org.springframework.ldap.core.DirContextAdapter (com.sun.jndi.ldap.LdapCtx is in module java.naming of loader 'bootstrap'; org.springframework.ldap.core.DirContextAdapter is in unnamed module of loader java.net.URLClassLoader @4f0f76b4)
我已将对象从 ContextMapper#mapFromContext 转换为 DirContextAdapter。 Spring-ldap 参考说,如果我不更改 DirObjectFactory LdapContextSource,此方法应返回 DirContextAdapter 的实例。
【问题讨论】:
标签: java spring-boot spring-ldap pooling