0

XPages application fails with following stack trace:

com.ibm.jscript.InterpretException: Script interpreter error, line=30, col=43: 'component' is null
at com.ibm.jscript.ASTTree.ASTMember.interpret(ASTMember.java:153)
at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:88)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
at com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
at com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
at com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
at com.ibm.jscript.ASTTree.ASTTry.interpret(ASTTry.java:109)
at com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
at com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
at com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)

From this I know, that there is problem with variable "component" nested inside hierarchy of blocks: if -> try -> { -> if -> { -> if -> { -> method call with invalid argument.

I don't know what to look for exactly, search for "component" yields too many results.

What regex should I use to find the right spot based on code hierarchy?

Frantisek Kossuth
  • 3,524
  • 2
  • 23
  • 42

2 Answers2

0

In this case I see a good chance that you have not put all your SSJS code into try/catch blocks. The bad news: searching the cause of this error is extremely cumbersome as close to all SSJS blocks may be the root cause of this error.

For that reason I placed my own rule (and ignore it every now and then) to put EVERY SSJS block into a try/catch like this:

try {
    // ... do fancy stuff here
} catch (e) {
    print(e.toString());
}

The toString() call is used for some special cases where the error object appears to no automatically convert into an object that can be handled by the print method.

If it is the case, you have not put all SSJS blocks into a try/catch, this is exactly the right time to do so and keep that coding pattern for the future. It really helps every now and then ;-)

  • Thanks for comment, unfortunately, your assumption is not correct. I have put my code in try/catch, and stacktrace in question is exact output of catch handler - e.printStackTrace() (to be exact, OpenLog manages to do it). Your e.toString() would return "com.ibm.jscript.InterpretException: Script interpreter error, line=30, col=43: 'component' is null" only, what does not help either. – Frantisek Kossuth Feb 26 '13 at 18:32
  • agree, that's not too helpful - but in the end it shows that the error occurred in the 30th line of one of your code blocks. So all that have less lines are out and that limits the number of code blocks to look for. When trying to find such a candidate, I take one of the blocks, enter one more line and check if the error changes to line 31. While this can still be cumbersome, I am able to find the erroneous line and get an idea of what really happens there. – Michael Gollmick Feb 27 '13 at 07:21
  • I see the point, that is only way. But with quite complex project (~50 custom controls) it is not easy to go through every event handler to catch this. I am looking for some help with that. I have found that error already, but it took more time than expected. I think R9 with SSJS debugger will make this question obsolete... – Frantisek Kossuth Feb 27 '13 at 08:46
0

Instead of printStackTrace and toString() , you could just say print(e), which will output only the error message(should be the same as e.message). The error object if passed to a java routine, you could get the error line.

variable "component" nested inside hierarchy of blocks ==> We have made this working without issues.