-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
None
-
beta2
-
sparc
-
solaris_2.6
Here is the customer's report:
Date: Thu, 31 May 2001 13:30:06 +0100
From: "Jenner, Mark" <###@###.###>
Subject: Problem closing connections after using DirContext.getSchema()
To: ###@###.###
Hi,
I am using the DirContext.getSchema(String name) method to retrieve schema
information from my Netscape directory. However this method seems to
prevent the connection from closing properly. I have reproduced my sample
code below.
If I do not use the getSchema call then by watching the cn=monitor tree I
see the connection to my server disappear when I call close on dirCtx, which
is what matches what the JNDI tutorial says. However, when I use getSchema,
the connection does not disappear until the JVM exits, even though I call
close on both Contexts. This is a major problem for me since this code will
be inside a servlet and the JVM should not be exiting... I tried garbage
collecting as well but that didn't make a difference.
I am using:
version: Netscape-Directory/4.12 B00.195.0645
SunOS 5.6 Generic_105181-23 sun4u sparc SUNW,Ultra-Enterprise
The latest JNDI I could find: jndi112 & ldap103
I have tried Java 1.2.1, 1.2.2 and 1.3.0
Any help with this problem would be greatly appreciated.
Thanks,
Mark
###@###.###
--------------------------------------------
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class TestJNDI
{
public static void main(String[] args)
throws Exception
{
DirContext dirCtx;
Hashtable ldapEnv = new Hashtable(5);
ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
ldapEnv.put(Context.PROVIDER_URL, "ldap://drkblondvws013");
ldapEnv.put(Context.SECURITY_PRINCIPAL,
"uid=jennerm,ou=People,o=dresdnerkb.com");
ldapEnv.put(Context.SECURITY_CREDENTIALS, "password");
ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
// Use this to pause at useful points
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
System.out.println("1 Making connection...");
dirCtx = new InitialDirContext(ldapEnv);
System.out.println("2 Getting schema...");
DirContext schema = dirCtx.getSchema("");
schema.close();
System.out.println("3 Press enter to close initial context...");
br.readLine();
dirCtx.close();
System.out.println("4 The connection should be closed...");
br.readLine();
Runtime.getRuntime().gc();
Runtime.getRuntime().runFinalization();
System.out.println("5 Perhaps not, did garbage collecting help?...");
br.readLine();
}
}
Date: Thu, 31 May 2001 13:30:06 +0100
From: "Jenner, Mark" <###@###.###>
Subject: Problem closing connections after using DirContext.getSchema()
To: ###@###.###
Hi,
I am using the DirContext.getSchema(String name) method to retrieve schema
information from my Netscape directory. However this method seems to
prevent the connection from closing properly. I have reproduced my sample
code below.
If I do not use the getSchema call then by watching the cn=monitor tree I
see the connection to my server disappear when I call close on dirCtx, which
is what matches what the JNDI tutorial says. However, when I use getSchema,
the connection does not disappear until the JVM exits, even though I call
close on both Contexts. This is a major problem for me since this code will
be inside a servlet and the JVM should not be exiting... I tried garbage
collecting as well but that didn't make a difference.
I am using:
version: Netscape-Directory/4.12 B00.195.0645
SunOS 5.6 Generic_105181-23 sun4u sparc SUNW,Ultra-Enterprise
The latest JNDI I could find: jndi112 & ldap103
I have tried Java 1.2.1, 1.2.2 and 1.3.0
Any help with this problem would be greatly appreciated.
Thanks,
Mark
###@###.###
--------------------------------------------
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class TestJNDI
{
public static void main(String[] args)
throws Exception
{
DirContext dirCtx;
Hashtable ldapEnv = new Hashtable(5);
ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
ldapEnv.put(Context.PROVIDER_URL, "ldap://drkblondvws013");
ldapEnv.put(Context.SECURITY_PRINCIPAL,
"uid=jennerm,ou=People,o=dresdnerkb.com");
ldapEnv.put(Context.SECURITY_CREDENTIALS, "password");
ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
// Use this to pause at useful points
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
System.out.println("1 Making connection...");
dirCtx = new InitialDirContext(ldapEnv);
System.out.println("2 Getting schema...");
DirContext schema = dirCtx.getSchema("");
schema.close();
System.out.println("3 Press enter to close initial context...");
br.readLine();
dirCtx.close();
System.out.println("4 The connection should be closed...");
br.readLine();
Runtime.getRuntime().gc();
Runtime.getRuntime().runFinalization();
System.out.println("5 Perhaps not, did garbage collecting help?...");
br.readLine();
}
}