Results 1 to 4 of 4
  1. #1
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default Why do I get java.lang.NullPointerException only for a specific file ?

    Hi,

    I've a 74MB xml document and I've split it into 2 docs:52MB and 22MB respectively.

    I'm parsing the file using common Digester library, and everything works perfectly for the small file, but I get a NullPointerExceptio with the big one.

    I don't think the issue is the code because it works for the small file... I guess the problem is with the file itself.

    I've parsed the files with the same parser, so I don't think the files have issues either.

    In conclusion I dunno where the issue is. This is the code: #1726063 - Pastie

    And these are the files:
    http://dl.dropbox.com/u/72686/test.xml
    http://dl.dropbox.com/u/72686/train.xml

    thanks

    This is the exception
    SEVERE: End event threw exception
    java.lang.reflect.InvocationTargetException
    at sun.reflect.GeneratedMethodAccessor7.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.commons.beanutils.MethodUtils.invokeMet hod(MethodUtils.java:216)
    at org.apache.commons.digester.SetNextRule.end(SetNex tRule.java:220)
    at org.apache.commons.digester.Rule.end(Rule.java:257 )
    at org.apache.commons.digester.Digester.endElement(Di gester.java:1345)
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.endElement(AbstractSAXParser.java:601)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanEndElement(XMLDocumentFra gmentScannerImpl.java:1782)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDriver.next(XM LDocumentFragmentScannerImpl.java:2938)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(XMLDocumentFragm entScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserI mpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at org.apache.commons.digester.Digester.parse(Digeste r.java:1871)
    at CentroidGenerator.main(CentroidGenerator.java:137)
    Caused by: java.lang.NullPointerException
    at CentroidGenerator.nextItem(CentroidGenerator.java: 62)
    ... 19 more
    Exception in thread "main" java.lang.NullPointerException
    at org.apache.commons.digester.Digester.createSAXExce ption(Digester.java:3363)
    at org.apache.commons.digester.Digester.createSAXExce ption(Digester.java:3389)
    at org.apache.commons.digester.Digester.endElement(Di gester.java:1348)
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.endElement(AbstractSAXParser.java:601)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanEndElement(XMLDocumentFra gmentScannerImpl.java:1782)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl$FragmentContentDriver.next(XM LDocumentFragmentScannerImpl.java:2938)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumen tFragmentScannerImpl.scanDocument(XMLDocumentFragm entScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Co nfiguration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLPars er.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.Abstrac tSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserI mpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at org.apache.commons.digester.Digester.parse(Digeste r.java:1871)
    at CentroidGenerator.main(CentroidGenerator.java:137)
    Caused by: java.lang.NullPointerException
    at CentroidGenerator.nextItem(CentroidGenerator.java: 62)
    at sun.reflect.GeneratedMethodAccessor7.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.commons.beanutils.MethodUtils.invokeMet hod(MethodUtils.java:216)
    at org.apache.commons.digester.SetNextRule.end(SetNex tRule.java:220)
    at org.apache.commons.digester.Rule.end(Rule.java:257 )
    at org.apache.commons.digester.Digester.endElement(Di gester.java:1345)
    ... 12 more

    thanks

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    What code do you have at CentroidGenerator.java: line 62?
    Also check the API specs for the org.apache.commons.digester.Digester.parse method to see if they mentioned any conditions that may cause it to throw a NPE.

  3. #3
    aneuryzma is offline Member
    Join Date
    Aug 2008
    Posts
    46
    Rep Power
    0

    Default

    I've solved the issue was a row in the file. To solve the issue I've printed the source file rows while processing. However it has been possible only because the parsing takes 4 minutes.

    I'm wondering how to debug such issues with a much bigger text file.

    thanks

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Juist assume that every line can be invalid and make sure that your code handles all possible invalid entries.

Similar Threads

  1. Replies: 15
    Last Post: 01-13-2011, 07:28 PM
  2. java.lang.NullPointerException
    By peterhabe in forum New To Java
    Replies: 5
    Last Post: 08-27-2010, 09:43 PM
  3. java.lang.NullPointerException
    By nitinverma in forum CLDC and MIDP
    Replies: 4
    Last Post: 06-15-2010, 04:56 PM
  4. java.lang.NullPointerException
    By Pombi in forum New To Java
    Replies: 6
    Last Post: 05-15-2010, 04:12 PM
  5. Replies: 6
    Last Post: 05-14-2008, 05:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •