↓ Skip to main content
An ink and watercolour drawing of a large magnifying glass with a wooden handle lying on a sheet of paper covered in wavy pen lines. Three small orange flags mark lines along the right edge of the sheet, and a teal pencil lies beside it.

Debugging Scripts and the Warnings Framework

Maximo Automation Scripts - This article is part of a series.
Part 31: This Article
A script fails in one of three ways: it does not save, it stops with an error, or it does nothing and says nothing. Each needs a different look. This article shows all three, and the warnings framework that is meant to catch problems before they run, with its rules as we found them on a 9.2 system.

We checked IBM’s pages against the behaviour of Manage in the MAS 9.2 series, and we read the warning rules and the scan schedule on our test system. Where the pages and Manage disagree, this page follows Manage.

Three ways a script fails
#

It does not save
#

Manage compiles a script when you save it. A syntax error refuses the save with BMXAA7836E, “The script did not compile”. The typical causes are language level: newer Python or JavaScript syntax that the engines in Manage do not accept. Article 2 lists what each engine refuses.

It stops with an error
#

A run that fails shows a message of this shape. One of our own test scripts produced it, here with the script renamed:

BMXAA7837E - An error occured that prevented the MYSCRIPT script for the null launch
point from running. java.lang.ClassNotFoundException: ... in <script> at line number 22

The message carries three useful facts: the script name, the launch point (null when the script ran without one, as through the REST API), and the line number in the script. The part in the middle is the error that Java or Python raised.

Two traps in Jython made our own test scripts fail this way:

  • except Exception misses Java errors. A Java exception, such as a class that is not found, is outside Python’s exception tree. Catch java.lang.Throwable when a Java call may fail.
  • globals() can end the request. In a script called through the REST API, a call to globals() ended the request with BMXAA1649E, a NullPointerException. To test whether a name exists, use eval(name) and catch NameError.

It does nothing and says nothing
#

These cases raise no error at all:

CaseWhat happens
The script is inactiveit is skipped; a REST call answers HTTP 200 with an empty body
A cron task script failsthe error is logged, and the cron task run counts as done
An after commit script failsthe error is logged; the user sees a successful save
A function of a callback script is missingit is skipped
A callback script lacks the function flagthe body runs once, and no function is called
An MXERR script failsthe error is printed to the console, and the message stays as it was

For these, the log is the only witness. Set the script’s own Log Level to DEBUG, and Manage writes the launch point, every variable value and the run time. Article 14 shows how. To repeat a failing case, article 30 shows two ways to test.

The warnings framework
#

Manage can scan scripts for patterns that cause trouble. The scan is a cron task, SCRIPTWARN. On our test system it was active and ran every 12 hours as MAXADMIN, and it had stored 366 warnings for 89 active scripts.

How the warnings scan works How the warnings scan works
How the warnings scan works

How the scan behaves:

  • It scans compiled scripts only. A script that failed to compile is never scanned.
  • Comments count, unless they start the line. A line is skipped only when # or // stands in the first column. An indented comment is scanned, and a match there counts.
  • Line numbers can be lower than in the editor, because skipped lines are not counted.
  • Patterns are text. The scan does not parse the code, so a match inside a string or a trailing comment counts too.
  • Warnings stay until you resolve them. The scan never removes or reopens a warning. A fixed script keeps its old warnings until someone sets Resolved, with a resolution text.

The rules, as we found them
#

The rules are data, so a system can differ. These were active on our test system:

CodeWhat it flagsNote
BMXAA10015Wa save() callonly in scripts with an object or attribute launch point
BMXAA10018Wloading the Mozilla compatibility scriptJavaScript only
BMXAA10019Wan object init launch pointfor every such launch point, active or not
BMXAA10022Wseveral scripts on one launch point eventnever fires
BMXAA10023W, BMXAA10024Wprintthe first for JavaScript, the second for Jython
BMXAA10025Wan assignment to errorkeyuse service.error
BMXAA10027W= MXServer()a server object built by hand
BMXAA10028Wa set from getMboSet(name, userInfo) without cleanup()counts lines; three-argument calls are not counted
BMXAA10030Wan assignment to warnkeynot in IBM’s table
BMXAA10039Wa Manage service created by handnot in IBM’s table
BMXAA10041Wmore database connections taken than freednot in IBM’s table

Two gaps matter:

  • The conflict warning BMXAA10022W never fires. The check that should find several scripts on one event can never report one, and it looks only at the launch points of the one script it scans. Article 29 shows how to get a real order instead.
  • The count() warning BMXAA10026W was missing. IBM’s table lists it, and our test system had no rule for it. The check class meant for it could never warn anyway.

So a script without warnings is not proven clean. The scan catches patterns, and two of its promises are empty.

What IBM’s pages get wrong here
#

TopicIBM’s pagesWhat Manage does
The conflict warningflags several scripts on one eventnever fires
The count() warningflags count() in loopsno rule on our test system; its check could never warn
The save warningflags save callsonly in scripts with an object or attribute launch point
The rule tablelists the warning codesthree more active rules exist

Article 33 of this series collects the corrections that matter most.

What comes next
#

Article 32 covers writing automation scripts in TypeScript.

IBM’s own pages are the reference to keep next to this series:

The complete list of corrections, with the evidence for each one, is in our member area. Members get access on request, so get in touch if you want it. If you want help with the scripts in your own Manage, our services page shows how we work.

IBM and Maximo are trademarks of International Business Machines Corporation, registered in many jurisdictions worldwide.

Maximo Automation Scripts - This article is part of a series.
Part 31: This Article