NullPointerException Error
Running this script:
// Output a message to the log so we know that we'll be writing the text out to a file.
session.log( "Writing data to a file." );
// Create a FileWriter object that we'll use to write out the text.
out = new FileWriter( "hockey_stats.txt" );
// Write out the text.
out.write( session.getVariable( "modano_name" ) );
//out.write( session.getVariable( "modano_goal" ) );
//out.write( session.getVariable( "modano_assist" ) );
// Close the file.
out.close();
with this pattern text:
NullPointerException Error
Thanks Todd, it works great now!!
NullPointerException Error
For the benefit of those who read this thread after the fact, Daniel sent me his scraping session via email, and this was my response to him after looking it over.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hi Daniel,
This error is happening because you forgot to save the value extracted by the "modano_name" token in a session variable. That is, in your script you're trying to write out the value of a session variable, but that session variable is null.
To resolve the issue, in your "modano" extractor pattern, double-click the "modano_name" extractor pattern token to edit it, then check the box labeled, "Save in session variable?"
Kind regards,
Todd
NullPointerException Error
It may just be that you're invoking the script at the wrong time. I'd need to see the scraping session to know for sure.
Best,
Todd
Error
I was getting the same message and it was becasue the object I was referencing didn't exist. I don't know if this helps.
NullPointerException Error
Hi,
Offhand, I can't spot anything wrong with that script. If you'd like to export ([url]http://www.screen-scraper.com/support/docs/importing_and_exporting_objects.php[/url]) your scraping session and send it to me, I'd be happy to take a closer look at it for you. My email address is my first name at screen-scraper.com.
Kind regards,
Todd Wilson