NoClassDefFoundError for javax.naming.InitialContext (jndi.jar) under java 1.2 �∂
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Richard_Robinson
Posted On:   Thursday, August 30, 2001 12:30 PM

Hello I'm trying to get up to speed on JNDI. So I wrote a very basic class, LDAPLookup.java, which uses javax.naming.Context and javax.naming.InitialContext (I copied the code, with slight modifications, directly out of the O'Reilly Enterprise Java in a Nutshell book, p. 145.) I can compile the class fine under JDK 1.2, as follows (in QSHELL): "javac -J-Djava.version=1.2 LDAPLookup.java". If I add "-verbose" option, I can see that javax.naming.InitialContext is indeed loaded. But it is when I try to run the class that I get a NoClassDefFoundError for javax.naming.InitialContext. I run the class as follows (in QSHELL): "java -Djava.version=1.2 com.ldr   More>>


Hello




I'm trying to get up to speed on JNDI. So I wrote a very basic class, LDAPLookup.java, which uses javax.naming.Context and javax.naming.InitialContext (I copied the code, with slight modifications, directly out of the O'Reilly Enterprise Java in a Nutshell book, p. 145.)




I can compile the class fine under JDK 1.2, as follows (in QSHELL): "javac -J-Djava.version=1.2 LDAPLookup.java". If I add "-verbose" option, I can see that javax.naming.InitialContext is indeed loaded.




But it is when I try to run the class that I get a NoClassDefFoundError for javax.naming.InitialContext. I run the class as follows (in QSHELL): "java -Djava.version=1.2 com.ldr.ldap.LDAPLookup". If I add "-verbose" option to this command and rerun, I do not see the javax.naming.InitialContext being loaded.




I've got java 1.1.8 (default) also installed on the same machine (AS/400 model 170 running OS v4r5). CLASSPATH environment variable under java 1.1.8 is similar to that under java 1.1.2. with the exception that java 1.1.8 preprends some java 1.1.8 specific system stuff onto it.



In java 1.2 the CLASSPATH environment variable begins like this: ".:/QIBM/ProdData/Java400/jdk12/lib/ext/jndi.jar:/... ". Working with Object links (wrkln k), I can see that jndi.jar in jdk12/lib/ext is actually a symbolic link to jndi.jar in jdk12/lib.




Just for good measure (not sure I need it under Java 1.2), I created another symbolic link in "/QIBM/UserData/Java400/ext" pointing to the jndi.ja r in jdk12/lib. I realize JDK 1.3, which I don't have installed, requires this (as part of the new extension mechanism); not sure about JDK 1.2. But can't hurt. In any case, I did this after all else failed, and it still continued to fail.




Does anyone know why jndi.jar cannot be fou nd under JDK 1.2, but can under JDK 1.1.8? Also, why the JDK 1.2 compilation can find it, but the runtime cannot?

>    <<Less

Re: NoClassDefFoundError for javax.naming.InitialContext (jndi.jar) under java 1.2 &

Posted By:   Richard_Robinson  
Posted On:   Thursday, August 30, 2001 03:20 PM


I have continued to play around with it, but
am coming to wonder whether the JDK 1.22 on AS/400 supports standard
extensions, or what are now called optional packages, which would NOT
necessitate my modifying the CLASSPATH variable in this case.




In any case, I have added to my CLASSPATH environment variable, the
following two paths: "/QIBM/ProdData/Java400/lib/ext/ibmjndi.jar", and
"/QIBM/ProdData/Java400/lib/ext/jndi.jar".




Now I can compile and run without problems the
com.ldr.ldap.LDAPLookup.class under JDK 1.1.8 (note, not JDK 1.2)! I can
also compile in JDK 1.2, but when I try to run in JDK 1.22 (after
compiling successfully), it gives me the same ERROR as before. And using
the "-verbose" option tells me that it cannot load the
javax.naming.InitialContext.




So there is something about the JDK 1.22 runtime that is not working
correctly, it seems to me. Or probably it is still my ignorance. Or
maybe there is a class in the path before jndi.jar that is conflicting.
But I've looked, so far, at sun.boot.class.path and
os400.boot.class.path. There IS a different jndi.jar in
/QIBM/ProdData/Java400/ext, which is listed as second of 2 entries in
the java.ext.dirs System properties. But I've examined its internals and
it does have an InitialContext.class in javax/naming, so that cannot be
the cause of the NoClassDefFoundError.




I found a document on IBM's site at
http://www-4.ibm.com/software/network/directory/library/publications/jndidoc.guide.htm
called "IBM JNDI LDAP Provider Programming Guide" that states jndi.jar
and ibmjndi.jar must be included in the classpath and they require SDK
or JRE 1.2.2 or higher. (That they say "make sure ... included in
classpath" seems to indicate that JDK 1.22 on AS/400 is not supporting
the optional packages, or extension mechanism.)




But even "stranger" is that with these same two JARs in the classpath
(env variable), I can compile and run the LDAPLookup class IN JDK 1.18!
without problems. Another mystery, in that it is said clearly in
document that the two jars require JDK 1.2.2




Any ideas, comments, suggestions?

About | Sitemap | Contact