I found the problem. My JUnit code was originally caching the DirContext, opps. I forgot about that, as it was hidden in some base classes.
So after the first shutdown, and the next restart, I was still using the same DirContext from the previous run. And that was causing problems, for good reasons. Thanks for the help. -----Original Message----- From: Nick Faiz [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 28, 2005 5:11 PM To: Apache Directory Developers List Subject: Re: startup and shutdown of apache 0.9.2 programmatically 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> >
