dev@directory.apache.org
[Top] [All Lists]

Re: NullPointerException in assertSubtreeScope

Subject: Re: NullPointerException in assertSubtreeScope
From: Emmanuel Lecharny
Date: Tue, 12 Feb 2008 15:18:18 +0100
Icky Dude wrote:
Emmanuel,


Yes, the NPE occurs on line ScopeEvaluator.java:94 because dn is null.
 Yes node is non-null.

I get the NPE when initializing a DefaultDirectoryService (in what I
think is the simplest possible way).  I'm pretty sure I'm using right
bootstrap jars because I just built them and installed them into my my
M2_REPO):

...
./repository/org/apache/directory/server/apacheds-bootstrap-partition/1.5.2-SNAPSHOT/apacheds-bootstrap-partition-1.5.2-SNAPSHOT.jar
./repository/org/apache/directory/server/apacheds-schema-bootstrap/1.5.2-SNAPSHOT/apacheds-schema-bootstrap-1.5.2-SNAPSHOT.jar
...

I can reproduce the problem using the following code (sorry there are
some minor syntax problems having some problems cut-n-paste to my
webmail) :

--- begin code ---

import org.apache.directory.server.core.DefaultDirectoryService;
import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.server.protocol.shared.SocketAcceptor;
import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.SimpleByteBufferAllocator;
iimport javax.naming.NamingException;
import java.io.IOException;

class HelloWorldImaDirectory
{
        private static int LDAP_PORT = 389;
        
        public static void main( String[] args)
        {
                DefaultDirectoryService directoryService = new 
DefaultDirectoryService();
                LdapServer ldapServer = new LdapServer();
                        
                try
                {       
                directoryService.startup();
                ByteBuffer.setAllocator( new SimpleByteBufferAllocator() );
                ByteBuffer.setUseDirectBuffers( false );
                SocketAcceptor tcpAcceptor = new SocketAcceptor( null );        
                ldapServer.setSocketAcceptor( tcpAcceptor );
                ldapServer.setDirectoryService( directoryService );     
You have to add this line here :
directoryService.startup();

Otherwise the schemas won't be loaded, leading to NPE all over the execution...

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


<Prev in Thread] Current Thread [Next in Thread>