You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Robert Sanders (JIRA)" <di...@incubator.apache.org> on 2005/03/16 03:49:20 UTC

[jira] Created: (DIRNAMING-14) EnvKeys.SHUTDOWN fails to work inside main() method

EnvKeys.SHUTDOWN fails to work inside main() method
---------------------------------------------------

         Key: DIRNAMING-14
         URL: http://issues.apache.org/jira/browse/DIRNAMING-14
     Project: Directory naming
        Type: Bug
 Environment: WindowsXP SP2, Eclipse 3.1m5, JRE 1.5_02
    Reporter: Robert Sanders
 Assigned to: Phil Steitz 
    Priority: Minor


While the JUnit test code works correctly, when using a main() method to create an instance of the directory server via JNDI, then server is only shutdown if System.exit() is called, not when EnvKeys.SHUTDOWN is used to create a DirContext.  Example code:

public class Ldap2 {
	
	private Hashtable env = new Hashtable();

	public Ldap2() {
		env.put( Context.PROVIDER_URL, "ou=system" );
		env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory" );
		env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
		env.put( Context.SECURITY_CREDENTIALS, "secret" );
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		Ldap2 ldap = new Ldap2();
		ldap.run();
	}
	
	private void run() throws Exception {
		DirContext ctx = new InitialDirContext( env );
		try {
			System.out.println( ctx );
			String key = null;
			NamingEnumeration list = ctx.list("");

			while (list.hasMore()) {
			    NameClassPair nc = (NameClassPair)list.next();
			    System.out.println( nc );
			}
			
			ctx.close();
			ctx = null;
		} finally {
			Hashtable closeEnv = new Hashtable(env);
			closeEnv.put(EnvKeys.SHUTDOWN , "");
			new InitialDirContext( closeEnv );
			//System.exit(0);
		} 
	}

}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (DIREVE-146) EnvKeys.SHUTDOWN fails to work inside main() method

Posted by "Phil Steitz (JIRA)" <di...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/DIREVE-146?page=history ]

Phil Steitz reassigned DIREVE-146:
----------------------------------

    Assign To: Alex Karasulu  (was: Phil Steitz)

> EnvKeys.SHUTDOWN fails to work inside main() method
> ---------------------------------------------------
>
>          Key: DIREVE-146
>          URL: http://issues.apache.org/jira/browse/DIREVE-146
>      Project: Directory Server
>         Type: Bug
>   Components: server main
>  Environment: WindowsXP SP2, Eclipse 3.1m5, JRE 1.5_02
>     Reporter: Robert Sanders
>     Assignee: Alex Karasulu
>     Priority: Minor

>
> While the JUnit test code works correctly, when using a main() method to create an instance of the directory server via JNDI, then server is only shutdown if System.exit() is called, not when EnvKeys.SHUTDOWN is used to create a DirContext.  Example code:
> public class Ldap2 {
> 	
> 	private Hashtable env = new Hashtable();
> 	public Ldap2() {
> 		env.put( Context.PROVIDER_URL, "ou=system" );
> 		env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.ServerContextFactory" );
> 		env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
> 		env.put( Context.SECURITY_CREDENTIALS, "secret" );
> 	}
> 	
> 	/**
> 	 * @param args
> 	 */
> 	public static void main(String[] args) throws Exception {
> 		Ldap2 ldap = new Ldap2();
> 		ldap.run();
> 	}
> 	
> 	private void run() throws Exception {
> 		DirContext ctx = new InitialDirContext( env );
> 		try {
> 			System.out.println( ctx );
> 			String key = null;
> 			NamingEnumeration list = ctx.list("");
> 			while (list.hasMore()) {
> 			    NameClassPair nc = (NameClassPair)list.next();
> 			    System.out.println( nc );
> 			}
> 			
> 			ctx.close();
> 			ctx = null;
> 		} finally {
> 			Hashtable closeEnv = new Hashtable(env);
> 			closeEnv.put(EnvKeys.SHUTDOWN , "");
> 			new InitialDirContext( closeEnv );
> 			//System.exit(0);
> 		} 
> 	}
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira