Crear una nueva partición con Apache DS

Estoy tratando de crear partición compleja con Apache DS

        Dn dnApache = new Dn("ou=test,dc=Apache,dc=org");
        Entry entryApache = service.newEntry(dnApache);
        entryApache.add("objectClass", "top", "domain", "extensibleObject");
        entryApache.add("dc", "Apache");
        service.getAdminSession().add(entryApache);

Funciona bien y no tengo problemas. Pero cuando intenté crear una partición más compleja, así:

        Dn dnApache = new Dn("ou=test,dc=Apache,dc=org");
        Entry entryApache = service.newEntry(dnApache);
        entryApache.add("objectClass", "top", "domain", "extensibleObject");
        entryApache.add("dc", "Apache");
        service.getAdminSession().add(entryApache);

        Dn serviceDN = new Dn("ou=service,ou=test,dc=Apache,dc=org");
        Entry serviceEntry = service.newEntry(serviceDN);
        entryApache.add("objectClass", "top",  "organizationalUnit");
        entryApache.add("dc", "Service");
        service.getAdminSession().add(serviceEntry);

Tengo una excepción como esta:

org.apache.directory.api.ldap.model.exception.LdapSchemaViolationException: ERR_60 Entry ou=service,ou=test,dc=Apache,dc=org does not contain a STRUCTURAL ObjectClass
    at org.apache.directory.server.core.schema.SchemaInterceptor.assertObjectClasses(SchemaInterceptor.java:1493)
    at org.apache.directory.server.core.schema.SchemaInterceptor.check(SchemaInterceptor.java:951)
    at org.apache.directory.server.core.schema.SchemaInterceptor.add(SchemaInterceptor.java:1045)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.exception.ExceptionInterceptor.add(ExceptionInterceptor.java:188)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.admin.AdministrativePointInterceptor.add(AdministrativePointInterceptor.java:1201)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.authz.AciAuthorizationInterceptor.add(AciAuthorizationInterceptor.java:516)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.referral.ReferralInterceptor.add(ReferralInterceptor.java:249)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.authn.AuthenticationInterceptor.add(AuthenticationInterceptor.java:335)
    at org.apache.directory.server.core.api.interceptor.BaseInterceptor.next(BaseInterceptor.java:416)
    at org.apache.directory.server.core.normalization.NormalizationInterceptor.add(NormalizationInterceptor.java:127)
    at org.apache.directory.server.core.DefaultOperationManager.add(DefaultOperationManager.java:394)
    at org.apache.directory.server.core.shared.DefaultCoreSession.add(DefaultCoreSession.java:193)
    at org.apache.directory.server.core.shared.DefaultCoreSession.add(DefaultCoreSession.java:170)
    at EmbeddedADSVerTrunk.initDirectoryService(EmbeddedADSVerTrunk.java:218)
    at EmbeddedADSVerTrunk.(EmbeddedADSVerTrunk.java:234)
    at EmbeddedADSVerTrunk.main(EmbeddedADSVerTrunk.java:264)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

¿Podrías ayudarme?

Exception in this line:  service.getAdminSession().add(serviceEntry);
0
Fijo. Por favor véalo.
agregado el autor Java Dude, fuente
Regla 0 Siempre publique el rastro de pila completo ; Regla 1 Identifique la línea de código que arrojó la excepción.
agregado el autor Jim Garrison, fuente

1 Respuestas

Solucionado de tal manera:

    Partition testPartition = addPartition("test", "ou=test,dc=apache,dc=org");
    Partition servicePartition = addPartition("service", "ou=service,ou=test,dc=apache,dc=org");


    addIndex(infopulsePartition, "objectClass", "ou", "uid");
    addIndex(servicePartition, "objectClass", "ou", "uid");

    service.startup();

    if (!service.getAdminSession().exists(infopulsePartition.getSuffixDn())) {
        Dn dnApache = new Dn("ou=test,dc=apache,dc=org");
        Entry entryApache = service.newEntry(dnApache);
        entryApache.add("objectClass", "top", "domain", "extensibleObject");
        entryApache.add("dc", "Apache");
        service.getAdminSession().add(entryApache);
    }

    if (!service.getAdminSession().exists(servicePartition.getSuffixDn())) {
        Dn dnApache = new Dn("ou=service,ou=test,dc=apache,dc=org");
        Entry entryApache = service.newEntry(dnApache);
        entryApache.add("objectClass", "top", "domain", "extensibleObject");
        entryApache.add("dc", "Apache");
        service.getAdminSession().add(entryApache);
    }
0
agregado