No need to come back to the previous version.  The CoreContextFactory can still be used ask you saw Stefan but now with the DirectoryService provided.

To shed some light on what has happened: The initialization of the server no longer occurs through JNDI via the CoreContextFactory.  This was one of the aims of refactoring the server to remove JNDI.  JNDI is simply used in the solid state to manipulate entries as a simple wrapper around our internal APIs. 

Now you can just add the directoryService to the environment and rely on JNDI infrastructure to invoke the CoreContextFactory or you can bypass this by just creating your own LdapServerContext using on of the existing constructors.  Don't know if this is the "right thing to do" according to JNDI but it works.


On Sat, Oct 4, 2008 at 6:13 PM, Emmanuel Lecharny <> wrote:
Stefan Zoerner wrote:
Hi all,

currently I try to update the example on how to embedd ApacheDS in a WebApp

in order to let it work with ApacheDS 1.5.4. The API has been changed since 1.5.1 (for which the example has been created for), hence the source code examples do not work anymore.

My web app is already able to start and stop a 1.5.4 ApacheDS server via a ServletContextListener.

Now I have a question regarding an embedded client. In the example, a servlet connects to the server without wire protocol (embedded). It uses JNDI for that. The old cfg does not seem to work. An env like this


Hashtable<Object, Object> env = new Hashtable<Object, Object>();
env.put(Context.PROVIDER_URL, "");
env.put(Context.INITIAL_CONTEXT_FACTORY, CoreContextFactory.class.getName() );
env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
env.put(Context.SECURITY_CREDENTIALS, "secret");
env.put(Context.SECURITY_AUTHENTICATION, "simple");


causes an error, if the InitialContext is created:

javax.naming.ConfigurationException: Cannot find directory service in environment: {, java.naming.provider.url=, java.naming.factory.url.pkgs=org.apache.naming,,,ou=system,[B@1b6634c}


It seems that I have to do something like this:

env.put( DirectoryService.JNDI_KEY, directoryService );

yes, this is it.

as in AbstractServerTest. Is this right? In this case, I have to remember the DirectoryService instance somewhere. Solvable, but the old way was easier ...
The problem is that the DirectoryService is not known by the JNDI layer at this point. I don't exactly remember how it was before, maybe Alex can give you some good reason why it's not any more the case.

Maybe we have to come back to the previous version...

cordialement, regards,
Emmanuel Lécharny