2010-06-10 114 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"/>