omer c
omer c

Reputation: 81

Spring Embedded Server

I'm using spring 3.0.2 and ApacheDS 1.5.5 and I'm trying to run the embedded server using:

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

The content of the user.s.ldif file is :

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

But I always get this error:

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)

Any Ideas ? Thanks in advance!

Upvotes: 1

Views: 3952

Answers (2)

tom
tom

Reputation: 61

I experienced the same problem. The solution was to add the correct context as "root"-Attribute of ldap-server tag in Spring Security. In your case:

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

Upvotes: 6

Andrew Swan
Andrew Swan

Reputation: 13637

First off, I assume your LDIF file is actually split over several lines, as follows:

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

... otherwise you wouldn't even be getting as far as you are.

But to answer your question, the error happens because you're trying to add something (in this case an organizationalRole) to a context that doesn't exist (i.e. "dc=example,dc=com"). Try changing that context to one that does exist. I can't say what this would be without seeing your Spring bean file, but by default, Spring's embedded LDAP server uses a root of "dc=springframework,dc=org", so try changing your LDIF file to this:

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

I tested this with Spring 3.0.3.RELEASE and ApacheDS 1.5.5.

P.S. when posting to StackOverflow, please format your code, stack traces, test data etc. as code (e.g. in edit mode, highlight the relevant text and click the "Code sample" button). It makes your post much more readable and people are therefore more likely to help you.

Upvotes: 0

Related Questions