Okay problem solved.  There was some crazy error in the handler. I
replaced it with some boiler plate handler code and it ran.  Now I can
go through the handler to find out the problem.

Ray 

-----Original Message-----
From: Raymond Hooker (rhooker) 
Sent: Thursday, April 07, 2005 1:00 PM
To: 'Research Triangle Java User's Group mailing list.'
Subject: RE: [Juglist] SAX Parse Exception

It was worth a try but all three conditions are true. Actually I used a
FileDialog with LOAD option to grab the file name for an existing XML
file.  So the problem is not with the file itself unless I am not
understanding something about the parse method.

Here is another possibility.  The actual statement that gets the
NullPointerException is the following:

            throw new SAXParseException (
                e.getMessage () != null
                    ? e.getMessage ()
                    : e.getClass ().getName (),
                locator.getPublicId (), locator.getSystemId (),
                locator.getLineNumber (), locator.getColumnNumber (),
                e);

Since the error is on the line "throw new SAXParseException" that would
say that this operation got the NullPointerException? That seems a bit
odd as it is part of the standard package org.apache.crimson.parser.  

Ray

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of A. Kevin Baynes
Sent: Thursday, April 07, 2005 11:47 AM
To: Research Triangle Java User's Group mailing list.
Subject: Re: [Juglist] SAX Parse Exception

'Filerules' will not be null, because it is newly created, but that
doesn't mean that the file exists or that it is readable, etc.
Possibly try checking Filerules.exists(), Filerules.isFile(),
Filerules.canRead() ?

On Apr 6, 2005 6:58 PM, Raymond Hooker (rhooker) <[EMAIL PROTECTED]>
wrote:
> Pardon the basic question but I cannot see what the problem is.  I was

> going through the SAX tutorials using Eclipse 3.0.2 and Java SDK 
> 1.4.2_07.  Anyhow the following code gets throws
> java.lang.NullPointerException:
> 
>                 String rulesFile =
> fileDialog.getDirectory()+fileDialog.getFile();
>         // Use an instance of ourselves as the 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
>                     File Filerules = new File(rulesFile);
>                     SAXParser saxParser = factory.newSAXParser();
>                     saxParser.parse( Filerules, handler ); 
> <----Exception occurs here
> 
>                         } catch (Throwable t) {
>                     t.printStackTrace();
>                   }
> 
> I verified that by a breakpoint that the time of exception Filerules 
> was File object that is not null, and handler is a Echo instance.
> Echo is class that extends DefaultHandler.  Echo has a number of 
> methods to handle events like startDocument and startElement.
> According to the JavaDoc, I don't believe that the parse method is 
> supposed to throw a nullPointerException.  BTW the actual stack trace
is:
> 
> java.lang.NullPointerException
>         at
> org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:691)
>         at org.apache.crimson.parser.Parser2.parse(Parser2.java:337)
>         at
> org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:448)
>         at javax.xml.parsers.SAXParser.parse(SAXParser.java:345)
>         at javax.xml.parsers.SAXParser.parse(SAXParser.java:281)
>         at Tree.rulesTree.main(rulesTree.java:103)
> 
> I have tried various file contents.
> 
> Ray
> 
> _______________________________________________
> Juglist mailing list
> [email protected]
> http://trijug.org/mailman/listinfo/juglist_trijug.org
> 


--
~akb
_________________
A. Kevin Baynes

_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org

_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org

Reply via email to