directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Zoerner <ste...@labeo.de>
Subject Connecting the embedded way via JNDI: Cannot find directory service in environment
Date Sat, 04 Oct 2008 21:58:40 GMT
Hi all,

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

http://directory.apache.org/apacheds/1.5/embedding-apacheds-as-a-web-application.html

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.factory.initial=org.apache.directory.server.core.jndi.CoreContextFactory, 
java.naming.provider.url=, 
java.naming.factory.url.pkgs=org.apache.naming, 
java.naming.security.authentication=simple, 
java.naming.security.principal=uid=admin,ou=system, 
java.naming.security.credentials=[B@1b6634c}

---

It seems that I have to do something like this:

env.put( DirectoryService.JNDI_KEY, directoryService );

as in AbstractServerTest. Is this right? In this case, I have to 
remember the DirectoryService instance somewhere. Solvable, but the old 
way was easier ... Or am I totally wrong?

Thanks in advance,
     Stefan




Mime
View raw message