You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Kent Loving <KL...@Paradigm4.com> on 2001/01/08 18:35:32 UTC

SAX examples don't work with jdk1.2.2

I get java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
when I attempt to run the SAXCount and the SAXWriter samples from the xerces
binary distribution.

My system is Win NT 4 + SP5.

I've tried the xerces 1.2.3 and 1.2.0 binaries.

I have jdk 1.2.2 and 1.1.8 on my system.

WHAT I DID:
1) Open a DOS window.
2) Set
CLASSPATH=D:\j\xerces-1_2_3\xerces.jar;D:\j\xerces-1_2_3\xercesSamples.jar
3) set PATH=d:\j\jdk\bin and JAVA_HOME=d:\j\jdk [which point to jdk 1.2.2]
4) run the sample from the xerces-1_2_3 home directory:
D:\j\xerces-1_2_2>java sax.SAXCount data/personal.xml

I get:
java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:191)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:290)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:124)
        at
org.xml.sax.helpers.ParserFactory.makeParser(ParserFactory.java:129)
        at sax.SAXCount.print(SAXCount.java:127)
        at sax.SAXCount.main(SAXCount.java, Compiled Code)

OTHER CLUES:
If I repeat the above, except change step 3 so that PATH and JAVA_HOME point
to jdk1.1.8, then I get the expected answer:
data/personal.xml: 1152 ms (37 elems, 18 attrs, 26 spaces, 242 chars)

The dom.DOMCount example works correctly for both jdk 1.2.2 and 1.1.8

I can "see" the SAXParser class in the xerces.jar file using 1.2.2's jar -t
command.  Output from jar includes a line for the SAXParser:
 13640 Wed Dec 06 18:08:22 PST 2000
org/apache/xerces/parsers/SAXParser.class

My jdk1.2.2 version is: Classic VM (build JDK-1.2.2-001, native threads,
symcjit)

Kent Loving
Sr. Software Engineer
kloving@Paradigm4.com


Re: SAX examples don't work with jdk1.2.2

Posted by Andy Clark <an...@apache.org>.
Kent Loving wrote:
> I get java.lang.ClassNotFoundException: org.apache.xerces.parsers.SAXParser
> when I attempt to run the SAXCount and the SAXWriter samples from the xerces
> binary distribution.

I get this misleading error sometimes when the JVM picks up
classes from the wrong jar files. It would be great if someone
could diagnose the real reason this happens and figure out a
way for the parser to detect and report the correct cause in
the sample code.

> Well, never mind I guess.  It works with jdk1.3.  I just didn't want to be
> forced to use 1.1.x

I find it strange that it works in 1.3 and not 1.2.2 but
stranger things have been known to happen. :)

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org