NullPointerException with SAX

I have developed a CSV to XML parser using a JAXP with SAX Events to parse the CSV file into a DOM tree.
Well inside the parse() method I have the following code":
public void parse(InputSource input) throws IOException, SAXException
BufferedReader br = null;
if( input.getCharacterStream() != null )
br = new BufferedReader( input.getCharacterStream() );
else if( input.getByteStream() != null )
br = new BufferedReader( new InputStreamReader( input.getByteStream() ) );
else if( input.getSystemId() != null )
URL url = new URL( input.getSystemId() );
br = new BufferedReader( new InputStreamReader( url.openStream() ) );
else
throw new SAXException( "Objeto InputSource invalido" );
ContentHandler ch = getContentHandler();
ch.startDocument();
ch.startElement( "", "", "file", new AttributesImpl() );
this.parseInput( br );
ch.endElement( "", "", "file" );
ch.endDocument();
Problem is that whenever the app gets to the ch.startDocument() statement it throws an java.lang.NullPointerExecption. I have no idea why this is happening, I have tested the very same code with Xalan 2 and Xercer 2 parsers and it works without problems. But using the oracle xml parser v2 throws the Exception.
Is this a bug? should I set tome of the Transformer's attributes to an specifica value to avoid this? Where could I find more info on processing SAX events?
Thanks,
Fedro

Fedro,
Did you try it using XDK v10?

Similar Messages

  • Java.lang.NullPointerException with OracleXMLParser V2

    Hi,
    I am getting java.lang.NullPointerException with OracleXMLParser V2.
    Following is some of the code snippet. I am not sure where I am going
    wrong. I am using the SAXParser. I tried both FileReader as well as URL
    InputSources But I am getting the same error.
    Parser parser = new SAXParser();
    parser.setDocumentHandler(this);
    parser.setEntityResolver(this);
    parser.setDTDHandler(this);
    parser.setErrorHandler(this);
    try {
    FileReader fileReader = new FileReader(defaultFileName);
    //InputSource iSource = new InputSource(fileReader);
    URL myURL = new URL("http://ewdev02/ooppub01.xml");
    InputSource iSource = new InputSource(myURL.toString());
    parser.parse(iSource);
    //parser.parse("http://ewdev02/ooppub01.xml");
    catch (FileNotFoundException fe) {
    System.err.println("File Not Found!");
    catch (SAXParseException se)
    System.out.println("Sax Exception: " + se.getMessage());
    catch (IOException ioe)
    System.out.println("IO Exception: " + ioe.getMessage());
    catch (Exception e){
    System.out.println("Error Parsing: " + e.toString ());
    Here are some of my habdlers:
    public void startDocument() {
    System.out.println("Beginning of the Document!");
    public void endDocument() throws SAXException {
    System.out.println("End of the Document!");
    System.out.println("A total of " + n + "Records inserted in the database!");
    public void startElement(String elname) throws SAXException {
    if (elname.equalsIgnoreCase("DOCS")){
    System.out.println("Biginning of the document! Ignoring <Docs>");
    curColumn = new AIColumns();
    else if (elname.equalsIgnoreCase("DOC")){
    System.out.println("Begining of <DOC>");
    curColumn.flush();
    n++;
    currentElement = elname;
    System.out.println( currentElement );
    public void endElement(String elname) throws SAXException {
    if (elname.equalsIgnoreCase("DOC")){
    System.out.println("End of <DOC>");
    //Now call the function to insert in the database
    try {
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    } catch ( Exception e ) {
    System.err.print("Exception: ");
    System.err.println( e.getMessage() );
    return;
    ..... after this I insert the record into database.
    Your help is greatly appreciated.
    Best Regards,
    Chandra Shirashyad

    Hi,
    Can you please also post the stack trace for where the Null pointer exception is occurring?
    Thank you,
    Oracle XML Team
    null

  • Is there any possibility to combine XPath with SAX in Java?

    HI Gentlemen,
    I have an XML instance to parse. One solution works with XPath and Document builder. However, the tree in memory is too big so that I can not build it in my storage (8 GB). Does anyone of you know a method where I use an XPath expression (Java) to select a node but with a better parser (e g SAX) which is not so space hungry? Direct access of nodes is obligatory.
    Thanks, kind regards from
    Miklos HERBOLY

    As SAX  parsers do not build a DOM structure and XPath requires a DOM structure to select elements from, XPath is not usable with SAX, but some analysers support setting the XPath expressions to analyse before invoking the SAX parser and provide the result for XPath expressions.
    Refer
    https://code.google.com/p/xpath4sax/

  • Changing xmlschema while parsing with sax

    Hello world,
    I`m using the sax-parser (xerces) and i want to combine different schema-files to parse an xml-String;
    <root>
         <intervall>1,5</intervall>
         <nix>jetzt echt nix!</nix>
         <testtag>
              <text>huhu joe</text>
         </testtag>
         <theLast>das letzte element</theLast>
    </root>e.g. i want to parse the tag testtag with another schema ??
    does anyone have an idea or a sample coding ??
    thank you very much

    thank you for the reply, but i want to change the Schema file while parsing the xmlString with Sax, without manipulation the xmlString;
    the xml-String i get is fixed;
    wish you all a great sunday

  • Edit an XML file with SAX

    Dear all, I am so confused�.
    I have been trying for the last few days to understand how sax works� The only thing I understood is:
    DefaultHandler handler = new Echo01();
    SAXParserFactory factory = SAXParserFactory.newInstance();
            try {
                out = new OutputStreamWriter(System.out, "UTF8");
                SAXParser saxParser = factory.newSAXParser();
                saxParser.parse(file , handler);
            } catch (Throwable t) {
                t.printStackTrace();
            System.exit(0);
        }Ok, I assign the SAXParser the xml file and a handler. The parser parses and throws events that the handler catches. By implementing some handler interface or overriding the methods of an existing handler (e.g DeafultHandler class) I get to do stuff�
    But still, suppose I have implement startElement() method of DefaultHandler class and I know that the pointer is currently placed on an element e.g. <name>bob</name>. How do I get the value of the element, and if I manage to do that, how can I replace�bob� with �tom�?
    I would really appreciate any help given� just don�t recommend http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/ because although there are interesting staff in there, it does not solve my problem�

    Maybe SAX is not the right tool for you.
    With SAX, you implement methods like startElement and characters that get called as XML data is encountered by the parser. If you want to catch it or not, the SAX parser does not care. In your case, the "bob" part will be passed in one or more calls to characters. To safely process the data, you need to do something like build a StringBuffer or StringBuilder in the constructor of the class, and then in the startElement, if the name is one you want to read, set the length to zero. In the characters method, append the data to the StringBuilder or StringBuffer. In the endElement, do a toString to keep the data wherever you want.
    This works for simple XML, but may need to be enhanced if you have nested elements with string values that contain other elements.
    On the other hand, if your file is not huge, you could use DOM. With DOM, (or with JDOM, and I would expect with Dom4J -- but I have only used the first two) you do a parse and get a Document object with the entire tree. That allows you to easily (at least it is easy once you figure out how to do it) find a node like the "name" element and change the Text object that is its child from a value of "bob" to "tom". With DOM, you can then serialize the modified Document tree and save it as an XML file. SAX does not have any way to save your data. That burden falls to you entirely.
    Dave Patterson

  • How to add attribute to Element with SAX

    Hi,
    I'm parsing XML document with SAX using DefaultHandler.
    How can I add attribute to start tag?

    Is this right????????????Yes, it's right. Everything everybody except you has said in this thread has been right.

  • Processing unfinished stream with SAX

    Hi,
    I'm just writing some kind of a jabber plugin in java. I've decided to use sax for parsing server responses. However I've encountered a problem with sax.
    saxParser.parse(inputStream, this);Problem is, that events (such as startElement) are called after the connection (streams read method returns with -1) is closed. Is there any way to force sax to raise event as soon as the tag is read?
    Any help will be greatly appreciated.
    Regards
    Versor
    Edited by: versor on Nov 2, 2007 3:20 AM

    versor wrote:
    ... Problem is, that events (such as startElement) are called after the connection (streams read method returns with -1) is closed. Is there any way to force sax to raise event as soon as the tag is read? ...Fully circumvent the problem parsing the buffered stream.

  • Can I parse non-wellformed XML with SAX at all?

    Hi all,
    i was wondering whether its possible at all to parse XML that is not well formed with SAX.
    e.g. A HTML file that doesnt close tags and stuff like that.
    I tried implementing the fatal() method of the Handler in a a way that it consumes the exception but does not rethrow it.
    Also I tried setting the validation property to false. Both with no success.
    Any help would be appriciated.
    thx
    philipp

    Your experiments tell you the answer.
    If you have HTML tag soup, why not just run it through JTidy or HTMLTidy to make it into well-formed XHTML?

  • Java.lang.NullPointerException with FTP receiver

    Hi All,
    I have a java.lang.NullPointerException in the Runtime Workbench for my FTP Adapter, that is a receiver.
    At SXMB_MONI all the messages are successful.
    What this could be?
    Thanks in advance,
    Daniela

    Naveen,
    Thanks for your help.
    I took a look in RWB and it seems like there was an error when CC tried to connect with the FTP server. The last two messages are:
    Success -> Connect to FTP server "10.112.144.108", directory "\interfaces2\conversionesTest"
    Error -> Attempt to process file failed with Error occurred while connecting to the FTP server "10.112.144.108:22": java.lang.NullPointerException
    Do you think ii could be an conection error (login, port) or a wrong configuration in my CC?
    Thaks in advance,
    Daniela Machado

  • BUG? using own EntityResolver with SAX doesn't work

    Hello,
    I was experimenting with the oracle.xml.parser.XMLParser using
    the SAX interface.
    I've written a test program that instantiates a driver and
    registers my own handlers (which just print to System.out).
    I also have my own org.xml.sax.EntityResolver, it looks like
    this:
    public class SAXEntityResolver implements EntityResolver {
    public InputSource resolveEntity(String publicId,
    String systemId) throws SAXException, IOException {
    System.out.println("<<Call to resolveEntity>>");
    try { //assume it's a URL of some sort
    URL url=new URL(systemId);
    return new InputSource(url.openStream());
    catch (MalformedURLException e1) {
    try { //it's not a URL, assume a file spec
    FileInputStream fin=new FileInputStream(systemId);
    return new InputSource(fin);
    catch (FileNotFoundException e2) {
    return null;
    //don't understand it, let the parser handle it.
    when I parse the following xml file:
    <?xml version="1.0"?>
    <!DOCTYPE dinner SYSTEM "dinner.dtd">
    <dinner>
    <location planet="Earth">Alma 3</location>
    <time>12:30</time>
    <date>Vandaag</date>
    </dinner>
    The parser generates an error to my org.xml.sax.ErrorHandler
    which prints it to the screen. The output looks like this:
    [C:\temp\xml]java -cp c:\TEMP\xml\oracle\lib\xmlparser.jar;.
    SAXParseXML oracle.xml.parser.XMLParser dinner.xml
    Locater accepted: oracle.xml.parser.SAXLocator@6ba51a96
    document parsing start
    [error: Couldn't find external DTD 'dinner.dtd']
    element dinner start: null:4:1
    (other output follows with no more errors)
    It seems as if the Oracle XMLParser doesn't use my EntityResolver
    to resolve it's external entities (the dinner.dtd file in this
    case, the file is indeed there, trust me!), otherwise it would
    have printed the message seen in the code above (<<Call to
    resolveEntity>>). If you're wondering how I configured the
    systemId in the SAX parser, here's how:
    File f=new File(args[1]);
    InputSource src=new InputSource(new FileInputStream(f));
    src.setSystemId(f.toURL().toString());
    p.parse(src);
    Can you tell me why this is? (I use NT4 with jdk 1.2)
    I've tested the same thing with the IBM, Microstar and Sun
    parsers, and they all seem to work fine with this example...
    Hope to hear from you! (cc in with mail please)
    Erwin.
    null

    Thanks for the post. You have identified a bug which will be
    fixed in a maintenance release. Until that time you can parse a
    String type rather than a InputSource type in SAXParseXML.java as
    a workaround.
    Oracle XML Team
    http://technet.oracle.com
    Erwin Vervaet (guest) wrote:
    : Oracle XML Team wrote:
    : : Which version of the parser are you using? If not 1.0.0.3
    (the
    : : latest) try that version. If the problem still exists it
    would
    : : help if you could provide your test program.
    : The readme.html in the xmlparser_v1_0_0_3.zip file (I download
    it
    : on monday 8/2/1999) says: 'Oracle XML Parser 1.0.0.3.0'.
    : So that's not the problem, below are all the files of the test
    : program. The command I use to start the program is the
    following
    : (note that there cannot be a classpath clash problem!, I use
    Sun
    : jdk1.2 on NT4 SP4):
    : [C:\temp\xml]dir
    : Volume in drive C is unlabeled Serial number is 2C90:8BDE
    : Directory of C:\temp\xml\*
    : 11/02/99 10:50 <DIR> .
    : 11/02/99 10:50 <DIR> ..
    : 9/02/99 16:34 <DIR> aelfred
    : 9/02/99 21:56 <DIR> oracle
    : 8/02/99 17:44 <DIR> xml-ea2
    : 8/02/99 14:10 <DIR> xml4j
    : 9/02/99 22:44 <DIR> xp
    : 9/02/99 16:42 215 dinner.dtd
    : 9/02/99 23:03 167 dinner.xml
    : 8/02/99 15:23 438 ParseXml.java
    : 11/02/99 10:50 2.402 SAXDocHandler.class
    : 9/02/99 21:14 1.585 SAXDocHandler.java
    : 11/02/99 10:50 1.129 SAXEntityResolver.class
    : 9/02/99 22:04 737 SAXEntityResolver.java
    : 11/02/99 10:50 976 SAXErrHandler.class
    : 9/02/99 15:39 495 SAXErrHandler.java
    : 11/02/99 10:50 1.261 SAXParseXML.class
    : 9/02/99 22:09 629 SAXParseXML.java
    : 10.034 bytes in 11 files and 7 dirs 12.800 bytes
    : allocated
    : 201.152.512 bytes free
    : [C:\temp\xml]java -cp c:\temp\xml\oracle\lib\xmlparser.jar;.
    : SAXParseXML oracle.xml.parser.XMLParser dinner.xml
    : Here are the files:
    : //file SAXErrHandler.java
    : import org.xml.sax.*;
    : public class SAXErrHandler implements ErrorHandler {
    : public void warning(SAXParseException exception) throws
    : SAXException {
    : System.err.println("[warning: " + exception +
    : public void error(SAXParseException exception) throws
    : SAXException {
    : System.err.println("[error: " + exception + "]");
    : public void fatalError(SAXParseException exception)
    : throws SAXException {
    : System.err.println("[fatal error: " + exception + "]");
    : //file SAXEntityResolver.java
    : import org.xml.sax.*;
    : import java.net.*;
    : import java.io.*;
    : public class SAXEntityResolver implements EntityResolver {
    : public InputSource resolveEntity(String publicId, String
    : systemId) throws SAXException, IOException {
    : System.out.println("<<Call to resolveEntity>> " + publicId + "
    : + systemId);
    : try { //assume it's a URL of some sort
    : URL url=new URL(systemId);
    : return new InputSource(url.openStream());
    : catch (MalformedURLException e1) {
    : try { //it's not a URL, assume a file
    : spec
    : FileInputStream fin=new
    : FileInputStream(systemId);
    : return new InputSource(fin);
    : catch (FileNotFoundException e2) {
    : return null; //don't understand
    : it, let the parser handle it.
    : //file SAXDocHandler.java
    : import org.xml.sax.*;
    : public class SAXDocHandler implements DocumentHandler {
    : private Locator locator=null;
    : public void startDocument() throws SAXException {
    : System.out.println("document parsing start");
    : public void setDocumentLocator(Locator locator) {
    : System.out.println("Locater accepted: " + locator);
    : this.locator=locator;
    : public void startElement(String name, AttributeList atts)
    : throws SAXException {
    : System.out.println("element " + name + " start: "
    : + locate());
    : for (int i = 0; i < atts.getLength(); i++)
    : System.out.println("attribute " +
    : atts.getName(i) + "=" + atts.getValue(i) + " (" +
    atts.getType(i)
    : + ")");
    : public void characters(char[] ch, int start, int length)
    : throws SAXException {
    : System.out.println("char data: " + new
    : String(ch,start,length));
    : public void ignorableWhitespace(char[] ch, int start, int
    : length) throws SAXException {
    : System.out.println("ignoring some whitespace: " +
    : new String(ch,start,length));
    : public void endElement(String name) throws SAXException {
    : System.out.println("element " + name + " end: " +
    locate());
    : public void processingInstruction(String target, String
    : data) throws SAXException {
    : System.out.println("PI: " + target + "=" + data);
    : public void endDocument() throws SAXException {
    : System.out.println("document parsing end");
    : private String locate() {
    : if (locator!=null) {
    : return locator.getSystemId() + ":" +
    : locator.getLineNumber() + ":" + locator.getColumnNumber();
    : return "";
    : //file SAXParseXML.java
    : import org.xml.sax.*;
    : import org.xml.sax.helpers.ParserFactory;
    : import java.io.*;
    : public class SAXParseXML {
    : public static void main(String[] args) {
    : if (args.length>1) {
    : try {
    : Parser
    : p=ParserFactory.makeParser(args[0]);
    : p.setDocumentHandler(new
    : SAXDocHandler());
    : p.setErrorHandler(new
    : SAXErrHandler());
    : p.setEntityResolver(new
    : SAXEntityResolver());
    : File f=new File(args[1]);
    : InputSource src=new
    : InputSource(new FileInputStream(f));
    : src.setSystemId(f.toURL().toString());
    : p.parse(src);
    : catch (Exception e) {
    : e.printStackTrace();
    : //file dinner.xml
    : <?xml version="1.0"?>
    : <!DOCTYPE dinner SYSTEM "dinner.dtd">
    : <dinner>
    : <location planet="Earth">Alma 3</location>
    : <time>12:30</time>
    : <date>Vandaag</date>
    : </dinner>
    : //file dinner.dtd
    : <?xml version="1.0" encoding="UTF-8"?>
    : <!ELEMENT dinner (location, time, date?)>
    : <!ELEMENT location (#PCDATA)>
    : <!ELEMENT time (#PCDATA)>
    : <!ELEMENT date (#PCDATA)>
    : <!ATTLIST location country CDATA "Belgium">
    Oracle Technology Network
    null

  • Possible to overwrite parse method in DOM with SAX Handler?

    Hi,
    Is it possible to overwrite the parse method within DOM?
    What a want to do is:
         private Node parseXml( String text ) throws SAXParseException, SAXException, IOException, ParserConfigurationException
              SAXParserFactory factory = SAXParserFactory.newInstance();
                   factory.setNamespaceAware(true);
                   SAXParser parser = factory.newSAXParser();
                   TestHandler handler = new TestHandler();
                   // Parse the file
                   parser.parse(new InputSource(new StringReader(text)), handler);
              return (Node)handler.getRoot();
         } //end parseXml()The reason I want to use this is that within SAX I can write my own line counter so I keep a count of which node is on which line of text.
    What I was thinking is that I could use SAX to return DOM Nodes with the line number attached, possibly using the node.setUserData() method?!
    I have tried to play around with it and it doen't seem to work, can anyone help?
    Cheers Alex

    I have managaed to re-write my SAX parser to create a JTree, this works perfectly I can move through the tree and each line of text that corresponds to the node is highlighted.
    My problem is however that in my application I have used the DOM structure throughout so some of the functionality is lost.
    Is I understand that JAXP uses both SAX and DOM together, so I was wondering if it is possible to combine my sax parse method within the DOM?
    If anything is unclear please say and I will try and explain better. The main reason for doing this is that I want to keep a reference to which line of text each node of the dom tree represents. I have not been able to implemnet one in DOM however using SAX I have managed.
    Many thanks,
    Alex

  • How to Parse XML with SAX and Retrieving the Information?

    Hiya!
    I have written this code in one of my classes:
    /**Parse XML File**/
              SAXParserFactory factory = SAXParserFactory.newInstance();
              GameContentHandler gameCH = new GameContentHandler();
              try
                   SAXParser saxParser = factory.newSAXParser();
                   saxParser.parse(recentFiles[0], gameCH);
              catch(javax.xml.parsers.ParserConfigurationException e)
                   e.printStackTrace();
              catch(java.io.IOException e)
                   e.printStackTrace();
              catch(org.xml.sax.SAXException e)
                   e.printStackTrace();
              /**Parse XML File**/
              games = gameCH.getGames();And here is the content handler:
    import java.util.ArrayList;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    class GameContentHandler extends DefaultHandler
         private ArrayList<Game> games = new ArrayList<Game>();
         public void startDocument()
              System.out.println("Start document.");
         public void endDocument()
              System.out.println("End document.");
         public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes atts) throws SAXException
         public void endElement(String namespaceURI, String localName, String qualifiedName) throws SAXException
         public void characters(char[] ch, int start, int length) throws SAXException
              /**for (int i = start; i < start+length; i++)
                   System.out.print(ch);
         public ArrayList<Game> getGames()
              return games;
    }And here is the xml i am trying to parse:<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <Database>
         <Name></Name>
         <Description></Description>
         <CurrentGameID></CurrentGameID>
         <Game>
              <gameID></gameID>
              <name></name>
              <publisher></publisher>
              <platform></platform>
              <type></type>
              <subtype></subtype>
              <genre></genre>
              <serial></serial>
              <prodReg></prodReg>
              <expantionFor></expantionFor>
              <relYear></relYear>
              <expantion></expantion>
              <picPath></picPath>
              <notes></notes>
              <discType></discType>
              <owner></owner>
              <location></location>
              <borrower></borrower>
              <numDiscs></numDiscs>
              <discSize></discSize>
              <locFrom></locFrom>
              <locTo></locTo>
              <onLoan></onLoan>
              <borrowed></borrowed>
              <manual></manual>
              <update></update>
              <mods></mods>
              <guide></guide>
              <walkthrough></walkthrough>
              <cheats></cheats>
              <savegame></savegame>
              <completed></completed>
         </Game>
    </Database>I have been trying for ages and just can't get the content handler class to extract a gameID and instantiate a Game to add to my ArrayList! How do I extract the information from my file?
    I have tried so many things in the startElement() method that I can't actually remember what I've tried and what I haven't! If you need to know, the Game class instantiates with asnew Game(int gameID)and the rest of the variables are public.
    Please help someone...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    OK, how's this?
    public void startElement(String namespaceURI, String localName, String qualifiedName, Attributes atts) throws SAXException
              current = "";
         public void endElement(String namespaceURI, String localName, String qualifiedName) throws SAXException
              try
                   if(qualifiedName.equals("Game") || qualifiedName.equals("Database"))
                        {return;}
                   else if(qualifiedName.equals("gameID"))
                        {games.add(new Game(Integer.parseInt(current)));}
                   else if(qualifiedName.equals("name"))
                        {games.get(games.size()-1).name = current;}
                   else if(qualifiedName.equals("publisher"))
                        {games.get(games.size()-1).publisher = current;}
                   etc...
                   else
                        {System.out.println("ERROR - Qualified Name found in xml that does not exist as databse field: " + qualifiedName);}
              catch (Exception e) {} //Ignore
         public void characters(char[] ch, int start, int length) throws SAXException
              current += new String(ch, start, length);
         }

  • Java.lang.NullPointerException with and update statement

    Hello,
    I'm getting this exception:
    java.lang.NullPointerException
         phaseone.AlbumModel.updateImageTrackerAlbums(AlbumModel.java:313)
         phaseone.AlbumModel.processRequest(AlbumModel.java:228)
         phaseone.AlbumModel.doGet(AlbumModel.java:522)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    I have an open method called before this one that connects me to the database. It works fine and have it working with a bunch of other methods but this one gives me this exception. i've even hard coded the variable 'user' and 'albumNumber' with information that exists in the database. i can't see where this logical error is coming from. I appreciate the help. I've been on this for 3 1/2 hour going blind. thanks!!
    public boolean updateImageTrackerAlbums(String user, int albumNumber){
              PreparedStatement pstmt = null;
              boolean pass = false;
              String query = "update imagetracker set totalalbums = ? where username = ?";
              try{
              pstmt = conn.prepareStatement(query);
              pstmt.setInt(1, albumNumber);
              pstmt.setString(2, user);
             int x = pstmt.executeUpdate();
             if (x >= 1){
             pass = true;
              }catch(SQLException e){
                e.printStackTrace();
                return pass;
              }finally{
              DBUtil.closePreparedStatment(pstmt);
              return pass;
              }

    code3 wrote:
    The exception is pointing to this:
    pstmt = conn.prepareStatement(query);
    Do you understand anyway when a NullPointerException would be thrown? It will be thrown if you try to access/invoke an object reference which is actually null.
    Connection conn = null;
    pstmt = conn.prepareStatement(query); // Throws NPE because conn is null.

  • Java.lang.NullPointerException with ADF Module

    Hi,
    I am trying to build simple application like "How to Build a Simple UIX Search Form
    But my view is
    =====================================================
    SELECT EmIssue.ID,
    EmIssue.INITIATIVE_ID,
    EmIssue.NAME,
    EmIssue.DESCRIPTION
    FROM EM_ISSUE EmIssue
    =====================================================
    And I added new method at AppModuleImpl
    It is
    ViewObject Issue = findViewObject("EmIssueView1");
    System.out.println("***In setBindVars*****");
    String WhereClause = " EmIssue.NAME like '%issue%'";
    Issue.setWhereClause(WhereClause);
    System.out.println("***END setBindVars*****");
    Issue.executeQuery();
    =====================================================
    And the system raises error with java.lang.NullPointerException at line
    String WhereClause = " EmIssue.NAME like '%issue%'";
    Could any one tell me where is error in my code
    Thanks

    It is unlikely that NPE was raised on
    String WhereClause = " EmIssue.NAME like '%issue%'";
    It's more likely that NPE was thrown from
    Issue.setWhereClause(WhereClause);
    This would happen if Issue is null, which means that the findViewObject() method couldn't find a VO named "EmIssueView1". Make sure that the VO name is spelled corectly. Names are case sensitive.
    Thanks.
    Sung

  • Java.lang.NullPointerException with rich:pickList

    Hi every Body,
    I still getting a problem with my <rich:pickList> and really I need help. I got an error when executing the application, I debugged the application and I have notice that the problem cames from the PickList tag.
    the error is as follow:
    java.lang.NullPointerException
            at com.sun.facelets.util.FastWriter.write(FastWriter.java:77)
            at com.sun.facelets.StateWriter.write(StateWriter.java:116)
            at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.write(HtmlResponseWriter.java:495)
            at org.richfaces.renderkit.PickListRenderer.encodeItem(PickListRenderer.java:194)
            at org.richfaces.renderkit.PickListRenderer.encodeRows(PickListRenderer.java:152)
            at org.richfaces.renderkit.PickListRenderer.encodeSourceRows(PickListRenderer.java:209)
            at org.richfaces.renderkit.html.PickListRendererGen.doEncodeChildren(PickListRendererGen.jav
    a:344)
            at org.richfaces.renderkit.html.PickListRendererGen.doEncodeChildren(PickListRendererGen.jav
    a:258)
            at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
            at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
            at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
            at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
            at org.ajax4jsf.renderkit.html.AjaxOutputPanelRenderer.encodeChildren(AjaxOutputPanelRendere
    r.java:79)
            at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
            at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.ja
    va:271)
            at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
            at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
            at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
            at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
            at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
            at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
            at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
            at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
            at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
            at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:189)
            at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
            at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
            at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
            at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
            at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.jav
    a:411)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
    ava:317)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
            at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
            at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
            at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
            at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
            at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:73)
            at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)
            at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
            at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
            at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
            at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
            at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
            at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
            at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
            at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
    ava:230)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
            at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.j
    ava:230)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
            at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:27
    1)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
            at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
            at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
            at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProces
    sorTask.java:637)
            at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorT
    ask.java:568)
            at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTas
    k.java:813)
            at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultRead
    Task.java:341)
            at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
            at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
            at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
            at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106
    )     My backing bean:
    @Stateful
    @Name("adminAction")
    @Scope(ScopeType.SESSION)
    public class AdminActionBean implements AdminActionLocal {
    @Out(required=false)
       private List<Customer> companyNames;
       @Out(required=false)
       private ArrayList<SelectItem> companyNamesOption;
       @In(required=false)
       @Out(required=false)
       private List<Long> customersChoice = new ArrayList<Long>();
    public void selectCompanyNames(){
           setCompanyNames((List<Customer>) getEm().createQuery("select c from Customer c")
                        .getResultList());
       @Factory("companyNamesOption")
       public void selectCompanyNamesOption(){
           selectCompanyNames();
           for (int i=0;i <companyNames.size();i++){
               log.info("customers size =#0",companyNames.size());
               if(companyNamesOption== null)
                   companyNamesOption  = new ArrayList<SelectItem>();
               SelectItem item = new SelectItem(companyNames.get(i).getCustomerId(), companyNames.get(i)
    .getCompanyName(), companyNames.get(i).getCompanyName() );
               companyNamesOption.add(item);
               log.info("customers size2 =#0",customers.size());
    // getter and setter
    ...My .xhtml page:
    <rich:pickList id="customersChoice"  value="#{adminAction.customersChoice}">
                        <f:selectItems  value="#{companyNamesOption}" />
                    </rich:pickList>     When debugging, the message error is displayed exactly after the selectCompanyNamesOption() method.
    thank you very much
    cheers
    bibou

    bibou wrote:
    java.lang.NullPointerException
    at com.sun.facelets.util.FastWriter.write(FastWriter.java:77)I would consider it as a bug in Facelets. But you might also have done something seriously wrong with your RichFaces tag and the logic behind which caused this unexpected exception.
    For more accurate answers, try reposting this question at the RichFaces forum at JBoss.com, there where the RichFaces boys walk around. You see, you're here at a Sun forum where mainly Mojarra boys walk around.

Maybe you are looking for

  • How to send email notifications to customers?

    Hi All, We have a requirement to send 'Order Acknowledgement' email notification to customers when their order is booked. My question is how do you set up the workflow to pick up the email address of the customer. Any help is appreciated! Thanks

  • Free of Charge Sales Order to GTS

    All of our sales orders pulls over the price into GTS for license assignment; except for one sales order type.  This sales order type is for FOC sales orders.  I have checked the sales order type in the R/3 and the GTS system and it is listed.  Anyon

  • Some questions from a new dba.

    Hello. I'm on a quest to learn Oracle. But in learning I've hit acouple of things that seem confusing or contradictory. Maybe someone more experienced can help me understand thse. 1) When you mount but don't open the database, you'll get a "ORA-01219

  • OSB - x509 token handler

    Hello, I'm trying to develop a webservice with some policies associated: @Policies( { @Policy(uri = "policy:Wssp1.2-2007-EncryptBody.xml"), @Policy(uri = "policy:Wssp1.2-2007-SignBody.xml"), @Policy(uri = "policy:Wssp1.2-2007-Wss1.1-UsernameToken-Pla

  • Apple update this morning - now Safari won't run

    This morning my MACBook Pro 15 went through an Apple update, installing updates to Safari, iTunes and a security update.  Upon reboot, there was a crash notice and the message told me to hold down power button to shutdown and then restart.  After the