OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [xml-dev] Problems with setting up Xerces



Title: RE: [xml-dev] Problems with setting up Xerces

Hi
I am a newbie in xml and java,
but from what I see it is a class not found error,
You will have to make sure that org/xml/sax/helpers.*  package is there in your class.
I use VAJAVA and I import the xerces.jar to the ide and make sure that the package is there,
Or may be with the version of xerces, are you using the latest?,  

Best Regards
Rizwan

-----Original Message-----
From: Javier Ho [mailto:hochokchiat@yahoo.com.sg]
Sent: Wednesday, November 28, 2001 2:06 AM
To: xml-dev@lists.xml.org
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>