I have a default ApacheDS server launched for testing via <ldap-server/> element in my spring config. This is inside a webapp, and the context is loaded through a servlet context listener (if that makes any difference).
ApacheDSContainer implements both Lifecycle and DisposableBean. Both destroy methods get called, but neither checks the 'running' field before trying to shut down the ApacheDS server. The first shutdown works, but since the server is contacted over a socket, the second attempt hangs until the socket times out.
The easy fix is to just check the 'running' field in the stop() method and don't do anything if the server isn't running.