directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Faiz <n...@atlassian.com>
Subject Re: startup and shutdown of apache 0.9.2 programmatically
Date Thu, 29 Sep 2005 00:11:01 GMT
Can you send a copy of the LDAP error 80?

I start and stop ApacheDS for quite a few unit tests without seeing the 
problem you mention.

My startup code is identical to yours, more or less, but for the 
shutdown I don't bother accessing a shutdown configuration object from 
the Spring context:

public static void shutdownApacheEve() throws NamingException
{
Hashtable env = new ShutdownConfiguration().toJndiEnvironment();
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");
env.put(Context.PROVIDER_URL, "ou=system");

new InitialDirContext(env);
}

In both my shutdown and startup util methods I specify the 
CoreContextFactory as the JDNI context factory, not the 
ServerContextFactory .

On a side note, I've been working haphazardly on a memory partition for 
exactly this sort of testing. It takes way too long to write to the file 
system when you want to start and stop ApacheDS in hundreds of unit 
tests. The memory partition should be out available pretty soon (fingers 
crossed).

Cheers,
Nick

Gianmaria Clerici wrote:

> I am trying to start and stop apache 0.9.2 from my JUnit tests.
>
> This is the code I have.
>
> It starts just fine, and it seems to stop just fine.
>
> But then I start it again, even if there are no errors, it doesn’t 
> seem to work properly.
>
> I get some weird LDAP error 80.
>
> Can you suggest a better way to shut it down ?
>
> Am I missing something ?
>
> private void startApacheDS() throws NamingException {
>
> Properties env;
>
> ApplicationContext factory = new 
> FileSystemXmlApplicationContext("config/server.bridgestream.xml");
>
> ServerStartupConfiguration cfg = (ServerStartupConfiguration) 
> factory.getBean("configuration");
>
> env = (Properties) factory.getBean("environment");
>
> env.setProperty(Context.PROVIDER_URL, "ou=system");
>
> env.setProperty(Context.INITIAL_CONTEXT_FACTORY, 
> ServerContextFactory.class.getName());
>
> env.putAll(cfg.toJndiEnvironment());
>
> new InitialDirContext(env);
>
> }
>
> private void stopApacheDs() throws NamingException {
>
> Properties env;
>
> ApplicationContext factory = new 
> FileSystemXmlApplicationContext("config/server.bridgestream.xml");
>
> ShutdownConfiguration cfg = (ShutdownConfiguration) 
> factory.getBean("shutdownConfiguration");
>
> env = (Properties) factory.getBean("environment");
>
> env.setProperty(Context.PROVIDER_URL, "ou=system");
>
> env.setProperty(Context.INITIAL_CONTEXT_FACTORY, 
> ServerContextFactory.class.getName());
>
> env.putAll(cfg.toJndiEnvironment());
>
> new InitialDirContext(env);
>
> }
>
> Of course I added the bean for the shutdownConfiguration to the XML file:
>
> <bean id="shutdownConfiguration" 
> class="org.apache.ldap.server.configuration.ShutdownConfiguration">
>
> <constructor-arg value="default"/>
>
> </bean>
>


Mime
View raw message