When used as alert notifications, CLI scripts could not find Remote API entities unless they were declared with their fully qualified name. This was due to the script engine being initialized with an empty list of entity packages.
Created attachment 932644 [details]
test script with full path
Description of problem:
It appears that when running a CLI Script as an Alert Notification Implicit Variables are not available (org.rhq.core.domain class is not automatically imported)
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Create an Alert Definition on any resource, i.e. Availability goes Down and add a Notification type of CLI Script, use the attached simplelist.js which simply uses var criteria = new ResourceCriteria(); to search for a resource type and print the list.
2. Trigger your Alert, look at the History on that Alert and you'll see the CLI notification fails with:
3. Now add another CLI notification to the same alert definition with the attached simplelistfqn.js which uses full path var criteria = new org.rhq.core.domain.criteria.ResourceCriteria(); it works.
Using Implicit variables in notification cli scripts fail.
Implicit variables would work.
Created attachment 932656 [details]
test script with implicit variable
Fixed in master
Author: Thomas Segismont <email@example.com>
Date: Tue Sep 23 11:32:26 2014 +0200
Script engine was initialized with an empty list of core domain packages.
In the "real" CLI we can find it by scanning the lib directory. Here, we need to scan the core domain JAR by inspecting the classloader.
Re-used org.jboss.jandex module from the EAP6.3 base instead of importing a new lib or writing our own code.
time: 2014-09-24 15:05:16 +0200
author: Thomas Segismont - firstname.lastname@example.org
message: Bug 1135473 - Implicit Variables for CLI are not available if the script
is run as notification on an alert
Script engine was initialized with an empty list of core domain
In the "real" CLI we can find it by scanning the lib directory.
Here, we need to scan the core domain JAR by inspecting the
Re-used org.jboss.jandex module from the EAP6.3 base instead of
importing a new lib or writing our own code.
(cherry picked from commit
daacc1cef59ea804c8a6b373366b00396da1961c) Signed-off-by: Libor Zoubek <email@example.com>
Moving to ON_QA as available for test with build:
Verified on JON3.3 ER04
The alert history notification displays that the script simplelist.js ran successfully. Verified that both scripts does not display any failure in alert history notification.