directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@gmail.com>
Subject Re: Connecting the embedded way via JNDI: Cannot find directory service in environment
Date Sat, 04 Oct 2008 22:13:52 GMT
Stefan Zoerner wrote:
> 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 );

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
www.iktek.com
directory.apache.org



Mime
View raw message