NullPointerException in a FOR loop?

A scraper that has been running daily smoothly so far has given me an error some times lately. The error is:

NullPointerException (line 39): for ( i = 0 ; -- Null Pointer in Method Invocation

The full line of code that seems to be generating this ocasional errors is:

for( i = 0; i < postsdataSet.getNumDataRecords(); i++ )

Any idea what could be happening?

Thank you,
Boga

Is the "postsdataSet" set?

Is the "postsdataSet" set? That's all I can think of.

Yes. A few lines before the

Yes. A few lines before the FOR loop I have:

DataSet postsdataSet = scrapeableFile.extractData( session.getv("ALLPOSTSPAGE"), "Posts" );

And as I said, I run this scrape once a day without any errors scraping thousdands of posts. It´s only now that I have started seeing the error that I mentioned(the scrape continues succesfully though).

Do you see anything fishy in the way I am setting the dataset and using the extractData method?

cheers,
boga

I think you need to add some

I think you need to add some logging to track it down.

if (session.getv("ALLPOSTSPAGE")==null || session.getv("ALLPOSTSPAGE").equals(""))
        session.logWarn("Value not set!");
else
{
        DataSet postsdataSet = scrapeableFile.extractData(session.getv("ALLPOSTSPAGE"), "Posts");
        numRecords = postsdataSet.getNumDataRecords();
        session.log("==>Found " + numRecords + " matches");

        for (i=0; i<numRecords; i++)
        {
                session.log("+++Record " + i + " of " + numRecords);
        }
}