2010-06-10 149 views
1

我使用弹簧3.0.2和1.5.5 ApacheDS中,我尝试使用运行嵌入式服务器:春嵌入式服务器

<ldap-server ldif="classpath:conf/users.ldif" port="39999"/> 

的user.s.ldif文件的内容是:

dn: cn=The Postmaster,dc=example,dc=com 
objectClass: organizationalRole 
cn: The Postmaster 

但我总是得到这样的错误:

16566 [main] INFO org.apache.directory.server.protocol.shared.store. LdifFileLoader - Could not create entry ClientEntry 
dn: cn=The Postmaster,dc=example,dc=com 
objectclass: organizationalRole 
cn: The Postmaster 

org.apache.directory.shared.ldap.exception.LdapNam eNotFoundException: Cannot find a partition for 2.5.4.3=the postmaster,0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com 
at org.apache.directory.server.core.partition.DefaultPartitionNexus.getPartition(DefaultPartitionNexus. java:1082) 
at org.apache.directory.server.core.partition.DefaultPartitionNexus.hasEntry(DefaultPartitionNexus.java :1037) 
at org.apache.directory.server.core.interceptor.InterceptorChain$1.hasEntry(InterceptorChain.java:167) 
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.hasEntry(InterceptorChain.java :1300) 
at org.apache.directory.server.core.interceptor.BaseInterceptor.hasEntry(BaseInterceptor.java:159) 
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.hasEntry(InterceptorChain.java :1300) 
at org.apache.directory.server.core.interceptor.BaseInterceptor.hasEntry(BaseInterceptor.java:159) 
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.hasEntry(InterceptorChain.java :1300) 
at org.apache.directory.server.core.exception.ExceptionInterceptor.add(ExceptionInterceptor.java:154) 
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196) 
at org.apache.directory.server.core.referral.ReferralInterceptor.add(ReferralInterceptor.java:251) 
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196) 
at org.apache.directory.server.core.authn.AuthenticationInterceptor.add(AuthenticationInterceptor.java: 212) 
at org.apache.directory.server.core.interceptor.InterceptorChain$Entry$1.add(InterceptorChain.java:1196) 
at org.apache.directory.server.core.normalization.NormalizationInterceptor.add(NormalizationInterceptor .java:126) 
at org.apache.directory.server.core.interceptor.InterceptorChain.add(InterceptorChain.java:756) 
at org.apache.directory.server.core.DefaultOperationManager.add(DefaultOperationManager.java:260) 
at org.apache.directory.server.core.DefaultCoreSession.add(DefaultCoreSession.java:145) 
at org.apache.directory.server.core.DefaultCoreSession.add(DefaultCoreSession.java:122) 
at org.apache.directory.server.protocol.shared.store.LdifFileLoader.execute(LdifFileLoader.java:204) 
at org.springframework.security.ldap.server.ApacheDSContainer.importLdifs(ApacheDSContainer.java:237) 
at org.springframework.security.ldap.server.ApacheDSContainer.start(ApacheDSContainer.java:189) 

什么想法? 在此先感谢!

回答

0

首先,我认为你的LDIF文件实际上分成了几行,如下所示:

dn: cn=The Postmaster,dc=example,dc=com 
objectClass: organizationalRole 
cn: The Postmaster 

...否则你甚至不会被尽可能你得到。

但是要回答你的问题,错误发生的原因是你试图添加一些东西(在本例中是一个organizationalRole)到一个不存在的上下文(即“dc = example,dc = com”)。尝试将该上下文更改为存在的上下文。如果没有看到Spring bean文件,我不能说这是什么,但默认情况下,Spring的嵌入式LDAP服务器使用“dc = springframework,dc = org”的根目录,因此请尝试将LDIF文件更改为:

dn: cn=The Postmaster,dc=springframework,dc=org 
objectClass: organizationalRole 
cn: The Postmaster 

我用Spring 3.0.3.RELEASE和ApacheDS 1.5.5测试了这个。

P.S.当发布到StackOverflow时,请将代码,堆栈跟踪,测试数据等格式化为代码(例如,在编辑模式下,突出显示相关文本并单击“代码示例”按钮)。它使你的文章更具可读性,因此人们更可能帮助你。

6

我遇到了同样的问题。解决方案是在Spring Security中添加正确的上下文作为“root” - ldap-server标签的属性。 在你的情况:

<security:ldap-server ldif="classpath:foo.ldif" root="dc=example,dc=com"/>