[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [xml-dev] Problems with setting up Xerces
Hi Charlot,
Thanx so much for your email, i've included the exceptions handing codes
into my file. once again, no errors during compilation but at runtime,
here's the error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/xml/sax/helpers/D
efaultHandler
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
sorry to have to trouble you, but could u pls give me some advice? thank you =)
At 07:34 PM 11/28/2001 +0100, you wrote:
>try including this in the main
>
> DefaultHandler handler = new Echo();
> SAXParserFactory factory = SAXParserFactory.newInstance();
> try {
> out = new OutputStreamWriter(System.out,"UTF8");
> SAXParser saxParser = factory.newSAXParser();
> saxParser.parse(new File(argv[0]),handler);
> }
> catch (SAXParseException spe) {
> System.out.println("\n** Parsing error"
> + ", line " + spe.getLineNumber()
> + ", uri " + spe.getSystemId());
> System.out.println(" " + spe.getMessage());
> Exception x = spe;
> if (spe.getException() != null)
> x = spe.getException();
> x.printStackTrace();
> }
> catch (SAXException sxe) {
> Exception x = sxe;
> if (sxe.getException() != null)
> x = sxe.getException();
> x.printStackTrace();
> }
> catch (ParserConfigurationException pce) {
> pce.printStackTrace();
> }
> catch (Throwable t) {
> t.printStackTrace();
> }
> System.exit(0);
>
>----- Original Message -----
>From: "Javier Ho" <hochokchiat@yahoo.com.sg>
>To: <xml-dev@lists.xml.org>
>Sent: Wednesday, November 28, 2001 3:05 AM
>Subject: [xml-dev] Problems with setting up Xerces
>
>
> > Hi everyone =)
> >
> > I wrote a simple parser for xml using SAX. there is no
> > problem at compilation time. when i run the program
> > however, the following error is generated:
> >
> > Exception in thread "main"
> > java.lang.NoClassDefFoundError:
> > org/xml/sax/helpers/DefaultHandler
> > at java.lang.ClassLoader.defineClass0(Native
> > Method)
> > at java.lang.ClassLoader.defineClass(Unknown
> > Source)
> > at
> > java.security.SecureClassLoader.defineClass(Unknown
> > Source)
> > at java.net.URLClassLoader.defineClass(Unknown
> > Source)
> > at java.net.URLClassLoader.access$100(Unknown
> > Source)
> > at java.net.URLClassLoader$1.run(Unknown
> > Source)
> > at
> > java.security.AccessController.doPrivileged(Native
> > Method)
> > at java.net.URLClassLoader.findClass(Unknown
> > Source)
> > at java.lang.ClassLoader.loadClass(Unknown
> > Source)
> > at
> > sun.misc.Launcher$AppClassLoader.loadClass(Unknown
> > Source)
> > at java.lang.ClassLoader.loadClass(Unknown
> > Source)
> > at
> > java.lang.ClassLoader.loadClassInternal(Unknown
> > Source)
> >
> >
> > If there's anyone who can provide me with some clues
> > to what this error is, thank you so much beccause i've
> > been working on it for a week and have followed the
> > installation in setting classpath. have even tried to
> > install it as an extension to java. none of it work.
> >
> > here is my java source code. Please enlighten me on
> > any semantic errors that might have caused the runtime
> > error.
> >
> > Thank you so much folks!!
> >
> >
> > import java.io.*;
> > import org.xml.sax.*;
> > import org.xml.sax.helpers.DefaultHandler;
> > import javax.xml.parsers.SAXParserFactory;
> > import javax.xml.parsers.ParserConfigurationException;
> > import javax.xml.parsers.SAXParser;
> >
> > public class Echo extends DefaultHandler
> > { private static Writer out;
> >
> > public static void main(String[] args)
> > {
> > if(args.length != 1) {
> > System.out.println("Usage: cmd filename");
> > System.exit(1);
> > }
> >
> > //use an instance of ourselves as an SAX event
> > handler
> > DefaultHandler handler = new Echo();
> >
> > //use the default(non-validating) parser
> > SAXParserFactory factory =
> > SAXParserFactory.newInstance();
> >
> > try {
> > //set up output stream
> > out = new OutputStreamWriter(System.out, "UTF8");
> >
> > //parse the input
> > SAXParser saxParser = factory.newSAXParser();
> > saxParser.parse(new File(args[0]), handler);
> >
> > } catch(Throwable t) {
> > t.printStackTrace();
> > }
> >
> > System.exit(0);
> > }
> >
> > private void emit(String s) throws SAXException
> > {
> > try {
> > out.write(s);
> > out.flush();
> > } catch(IOException e) {
> > throw new SAXException("IO Error", e);
> > }
> > }
> >
> > private void nl() throws SAXException
> > {
> > String lineEnd =
> > System.getProperty("line.seperator");
> >
> > try {
> > out.write(lineEnd);
> > } catch(IOException e) {
> > throw new SAXException("IO Error", e);
> > }
> > }
> >
> > public void startDocument() throws SAXException
> > {
> > emit("<?xml version='1.0' encoding='UTF-8'?>");
> > nl();
> > }
> >
> > public void endDocument() throws SAXException
> > {
> > try {
> > nl();
> > out.flush();
> > } catch(IOException e) {
> > throw new SAXException("IO Error", e);
> > }
> > }
> >
> > public void startElement(String namespaceURI, String
> > sName, String qName,
> > Attributes attrs)
> > throws SAXException
> > {
> > String eName = sName;
> > if("".equals(eName)) //qualified name
> > eName = qName;
> >
> > emit("<" + eName);
> > if(attrs != null) {
> > for(int i = 0; i < attrs.getLength(); i++) {
> > String aName = attrs.getLocalName(i); //attribute
> > name
> > if("".equals(aName))
> > aName = attrs.getQName(i);
> > emit(" ");
> > emit(aName + "=\"" + attrs.getValue(i) + "\"");
> > }
> > }
> > emit(">");
> > }
> >
> > public void endElement(String namespaceURI, String
> > sName, String qName)
> > throws SAXException
> > {
> > emit("<" + sName + ">");
> > }
> >
> > public void characters(char buf[], int offset, int
> > len) throws SAXException
> > {
> > String s = new String(buf, offset, len);
> > emit(s);
> > }
> > }
> >
> > rgds,
> > Javier
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Shopping - Beat the crowds! Do your X'mas Shopping Online!
> > http://shopping.yahoo.com.sg/
> >
> > -----------------------------------------------------------------
> > The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> > initiative of OASIS <http://www.oasis-open.org>
> >
> > The list archives are at http://lists.xml.org/archives/xml-dev/
> >
> > To subscribe or unsubscribe from this list use the subscription
> > manager: <http://lists.xml.org/ob/adm.pl>
> >
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com