Menu

#330 Error HERE! thrown while SAX parsing

None
closed
nobody
None
5
2018-08-02
2009-11-15
Anonymous
No

I'm new to beanshell, so was trying out some of the examples. The documented invoke() example for SAX parsing doesn't work, here i've modifed it slightly to get the InputStream correctly set.

The following throws an error "HERE!" when run. This is on 2.0b4 (but similarly failed on 1.3)

- - - 8< - - -
import javax.xml.parsers.*;
import org.xml.sax.InputSource;

factory = SAXParserFactory.newInstance();
saxParser = factory.newSAXParser();
parser = saxParser.getXMLReader();
parser.setContentHandler( this );

invoke( name, args ) {
print( name );
}

source = new InputSource(new FileReader(new File(bsh.args[0])));
parser.parse( source );
- - - - -

the source xml i'm using is:

- - - 8< - - -
<?xml version="1.0" encoding="UTF-8"?>
<message text="hello" />
</message>
- - - - - -

The stack is:

setDocumentLocator
Script threw exception: Sourced file: parse.bsh : Method Invocation parser.parse : at Line: 14 : in file: parse.bsh : parser .parse ( source )

Target exception: java.lang.Error: HERE!

java.lang.Error: HERE!
at bsh.BshMethod.invoke(Unknown Source)
at bsh.BshMethod.invoke(Unknown Source)
at bsh.This.invokeMethod(Unknown Source)
at bsh.This.invokeMethod(Unknown Source)
at bsh.XThis$Handler.invokeImpl(Unknown Source)
at bsh.XThis$Handler.invoke(Unknown Source)
at $Proxy0.startDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startDocument(AbstractSAXParser.java:318)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startDocument(XMLDTDValidator.java:701)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.startEntity(XMLDocumentScannerImpl.java:540)
...

I've looked at the source, it seems that the invoke() is getting an array of argValues, but one of them is null, but i have no idea why.

Discussion

  • nickl-

    nickl- - 2018-08-02
    • status: open --> closed
    • Group: -->
     
  • nickl-

    nickl- - 2018-08-02

    Ticket has been migrated to github.
    Please follow up on this over here: https://github.com/beanshell/beanshell/issues/468

     

Log in to post a comment.