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

LDAP SDK and JNDI Question

4 views
Skip to first unread message

Mark Moales

unread,
Dec 1, 2000, 3:00:00 AM12/1/00
to
Hi,

I trying to write a simple program to bind a Java object using JNDI and
the SPI provided in the LDAP SDK (Directory Server 4.1). Here's a code
snippet from the program that tries to bind the object:

InitialContext = new InitialContext();
System.out.println(">> JNDI context created");
context.bind("hello", "World!");

I can create the context and do things like find users in the
directory. However, everytime I try to bind the object I get the
following exception:

javax.naming.NameNotFoundException: netscape.ldap.LDAPException: error
result (32); No such object
at
com.netscape.jndi.ldap.LdapService.addEntry(LdapService.java:464)
at
com.netscape.jndi.ldap.LdapContextImpl.bind(LdapContextImpl.java:370)
at javax.naming.InitialContext.bind(InitialContext.java:358)
at com.nextmark.test.JNDITest.main(JNDITest.java:42)
at sun.tools.agent.MainThread.runMain(Native Method)
at sun.tools.agent.MainThread.run(MainThread.java:45)

I updated the java-object-schema.conf file per the instructions in the
programmers guide and restarted my server. I assume I'm missing
something fairly fundamental here. If anyone could shed some light on
this, I'd really appreciate it.

Thanks,

Mark Moales


Mark Wilcox

unread,
Dec 3, 2000, 3:00:00 AM12/3/00
to Mark Moales
The problem has nothing to do with Java, or your configuration.
This line:

context.bind("hello", "World!");

is not valid in LDAP.

you must pass a valid DN as the first argument, and the argument must be an
object that can be stored in the directory (either a serializable java
class, which will end up being serialized into the directory as a java
object, a Reference object or an object that implements the DirContext
interface).

Either read up on bind in the JNDI tutorial at java.sun.com or read the
JNDI section in either my book "Implementing LDAP", or my chapters on JNDI
in Professional Java Server programming for more help.

Mark

Mark Moales

unread,
Dec 4, 2000, 3:00:00 AM12/4/00
to Mark Wilcox
Mark,

Thanks for the tips. They've got me going in the right direction now. I've
successfully bound a simple object in the directory. However, I tried binding
my database provider's data source object in the directory and get an error.
Here's the code snipet and error:

IfxDataSource ifxds = new IfxDataSource();
ifxds.setDescription("NextMark Data Source");
context.bind("cn=MyDataSource,ou=Java,o=nextmark.com", ifxds);

javax.naming.NamingException: Can not encode StringRefAddr, value starts with
the delimiter character #
at
com.netscape.jndi.ldap.ObjectMapper.encodeRefAddr(ObjectMapper.java:428)
at
com.netscape.jndi.ldap.ObjectMapper.encodeRefObj(ObjectMapper.java:407)
at
com.netscape.jndi.ldap.ObjectMapper.objectToAttrSet(ObjectMapper.java:189)
at
com.netscape.jndi.ldap.LdapContextImpl.bind(LdapContextImpl.java:371)
at javax.naming.InitialContext.bind(InitialContext.java:358)
at com.nextmark.test.JNDITest.main(JNDITest.java:61)


at sun.tools.agent.MainThread.runMain(Native Method)
at sun.tools.agent.MainThread.run(MainThread.java:45)

I tried setting the java.naming.ldap.ref.separator property to something other
than '#', but I continue getting the same error. I've tried using the command
line method -Djava.naming.ldap.ref.separator=: and programmitically using a
Hashtable. Both give the same results. Any ideas?

Thanks again,

Mark Moales

Mark Moales

unread,
Dec 4, 2000, 3:00:00 AM12/4/00
to Mark Moales
The problem appears to be in the Netscape JNDI service provider. The
documentation says that they support the java.naming.ldap.ref.separator property
to change the separator character, but that doesn't appear to be the case. I
switched out the Netscape service provider with the one from Sun, and everything
seems to be working now.

Mark Moales

0 new messages