Remote scraping is throwing an error when scrape session contains a script

Hi,

I have a scraper that works fine on Workbench but not when invoked remotely.

To simplify debugging I created a simple scraper that loads a page (can be any page) and invokes a script after that is complete.

The script is very simple and is as follows:

// Import the necessary classes.
import com.screenscraper.scraper.*;
import com.screenscraper.csv.CsvWriter;
import java.util.*;
import java.text.SimpleDateFormat;

session.setVariable("DeviceList",new HashMap());

........

This works fine in the workbench but when I run it in server mode using the command

java -Xmx1024M -jar "screen-scraper.jar" -s "Test"

I get an error

Initializing screen-scraper...
Running script "Test"...
An error occurred while processing the script: Test Script.
The error message was: class bsh.EvalError (line 11): session .setVariable ( "DeviceList" , new HashMap ( ) ) -- Attempt to invoke method: setVariable() on undefined variable or class name: session

Wonder what I am missing as I need to migrate a bunch of scrapers to production and schedule them as crons ASAP.

It looks like your command

It looks like your command line is invoking a script directly. Is the script a part of a scraping session? Could you make sure the script is attached to a session, and your command line is calling the session. It should work then. As is, it's not in a session, and that's the cause of your error.

Duplicate script and scraper names

Jason,

Your comment helped me look at why that might be happening.

I was invoking the script from within the session but both my scraping session and main script had the same name and that was causing the issue. I renamed the main script and ran it and it works great now.

Thanks,

Vivek