Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JNDI LDAP problem in JRE 1.4

1 view
Skip to first unread message

Ray Dees

unread,
Sep 5, 2003, 4:05:31 PM9/5/03
to
I have a production app that worked under JRE 1.3.1 but gives an
exception under JRE 1.4.1 and 1.4.2. To illustrate the problem a
small example is shown below. This example is derived from the
SearchWithFilterRetAll example from Sun's JNDI Tutorial. The OS is
Solaris 8 & 9 (SPARC). Would appreciate any suggestions as to the
cause of the problem. Thanks!

import javax.naming.*;
import javax.naming.directory.*;

import java.util.Hashtable;

class filterTest {
public static void main(String[] args) {

Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,
"ldap://server:389/ou=myorgunit,o=organization, c=US");

try {
DirContext ctx = new InitialDirContext(env);
SearchControls ctls = new SearchControls();
String filter = "(&(sn=Smith)(mail=*))";
NamingEnumeration answer = ctx.search("", filter, ctls);
printSearchEnumeration(answer);
ctx.close();
} catch (Exception e) {
e.printStackTrace();
}
}

public static void printSearchEnumeration(NamingEnumeration enum)
{
try {
while (enum.hasMore()) {
SearchResult sr = (SearchResult)enum.next();
System.out.println(">>>" + sr.getName());
System.out.println(sr.getAttributes());
}
} catch (NamingException e) {
e.printStackTrace();
}
}
}


Here is the exception trace (from JRE 1.4.2):

javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such
Object]; remaining name ''
at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3013)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
at com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1811)
at com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1734)
at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:368)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:328)
at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:313)
at javax.naming.directory.InitialDirContext.search(InitialDirContext.java:238)
at filterTest.main(filterTest.java:18)

0 new messages