title: Embedded ApacheDS 2.0.0-M16 (on 2nd run only): ERR_250_ENTRY_ALREADY_EXISTS ou=system already exists
body: <p>Using <a href="https://issues.apache.org/jira/secure/attachment/12626473/EmbeddedADSVerTrunkV2.java" rel="nofollow">this example</a> as base, my embedded ApacheDS server runs fine the first time, then, when I stop the JBoss server on which my app runs and start again, and re-deploy, the log returns a load of errors starting with:</p>
  
  <p>'(ERROR [stderr] (MSC service thread 1-1) org.apache.directory.api.ldap.model.exception.LdapEntryAlreadyExistsException: ERR_250_ENTRY_ALREADY_EXISTS ou=system already exists!)'</p>
  
  <p>followed by others that have been accurately identified in this Apache <a href="https://issues.apache.org/jira/browse/DIRSERVER-1954" rel="nofollow">JIRA issue</a></p>
  
  <p>Every time I stop and start JBoss thereafter, the ApacheDS server starts just fine (same as in the JIRA issue)</p>
  
  <p>The JIRA page states that the issue has been fixed with a little workaround, which I have applied</p>
  
  <pre><code>public EmbeddedADSVerTrunkV2(final File workDir) throws Exception
  {
      if (!workDir.exists())
      {
          workDir.mkdirs();
          this.initDirectoryService(workDir);
          this.service.shutdown();
      }
  
      this.initDirectoryService(workDir);
  }
  </code></pre>
  
  <p>but the problem remains for me. The second run always fails before succeeding on the third and subsequent runs. </p>
  
  <p>Are there any new workarounds or fixes that I have missed? Many thanks!</p>