How to troubleshoot "Attempt to access method on primitive" error?
Hi,
I just exported to a Linux server a scrape that was running smoothly in my mac. When I run it from the Linux shell I get thousdands of this error:
// Error: Attempt to access method on primitive... allowing bsh.Primitive to peek through for debugging
I don´t have any more information so I don´t know what could be causing it. Also, why this error didn´t happen in my mac´s workbench environment?
thank you,
boga
That is just a warning. In
That is just a warning. In Java there is a distinction between an 'int' and an 'Integer'. You've a number cast as an int, and someplace it's being used as an Integer. Despite the warning, however, it should still work.
Sounds like a permissions problem...
I know I probably shouldn't be commenting here, but have you tried running any other scrapes on this Linux server? FWIW, it sounds to me like some kind of permissions issue, but I'm not sure where to begin troubleshooting this... Was SS logging at the time? If so, maybe you could post some of the log entries here.
Justin, thanks but I think
Justin, thanks but I think Jason must be right. I have several other scrapes running in this Linux machine without problem. Also, this same scrape that is now throwing these errors was running without errors until I recently introduced some minor modifications to the code(mainly some dates and numeric conditional checking).
I will take a look in the direction that Jason pointed out and will post again if/when I find the exact piece of code causing the errors.
While it´s true that the script executes successfully even with the errors, I normally monitor the daily run of it by sending myself an email with the error log. But now with thousdands of lines with that error it´s impossible for me to read the email in a practical way, so I need to get rid of them.
cheers,
boga
hello again. I have located
hello again. I have located the point that causes the mentioned errors. It´s the execution of this IF statement:
{
// exit loop
break;
}
The value of the session variable
DAYOFTODAY
is previously set in an init script executed at the beginning of the scrape like this:dayoftoday = todaysdate.get(Calendar.DAY_OF_MONTH);
session.setVariable( "DAYOFTODAY", dayoftoday);
and the variable
checkday
is set just before the if causing the error like this:Calendar caldate = Calendar.getInstance();
caldate.setTime(checkdate);
checkday = caldate.get(Calendar.DAY_OF_MONTH);
So what is the problem causing the IF to throw the mentioned error each time?
thanks you,
boga
This might be a shot in the dark...
Thanks for posting your code. FWIW, I'm still learning Java, but when you retrieve the DAYOFTODAY variable in your If statement, does it come back cast as a string or as a date? I could see a potential problem if SS returned this variable as a string b/c then you'd be trying to compare a string to a date. (Of course, I could be completely wrong...and probably am)
While looking at this, I also found a website that describes various ways to compare dates in Java (http://www.mkyong.com/java/how-to-compare-dates-in-java/); you probably know this already but I'm including it here in case others might find it useful for their scripts.
I am also learning Java. But
I am also learning Java. But to my understanding, in my IF I am comparing two variables that have been set with an integer value each, because Calendar.DAY_OF_MONTH returns an integer.
So I am not sure what the problem is with my IF.
Jason, what do you think?
thank you,
boga
I think that checkdate is the
I think that checkdate is the int, but if the scrape is working, I'd not worry about the message.
So any suggestion on how to
So any suggestion on how to get rid of the error?
The reason I need to worry about it because I monitor the daily execution of the scrape by emailing myself the log. But since this error is happening thousdands of times, the log emailed gets huge and filled with the errors.
I think if you change if
I think if you change
To
And ensure that DAYOFTODAY is also a valid number, that will get rid of the message.
that did it! Thank you very
that did it! Thank you very much!
boga.