Bug 743379
Summary: | CLI fails on running *.js files with error | ||||||
---|---|---|---|---|---|---|---|
Product: | [Other] RHQ Project | Reporter: | Nabeel Saad <nsaad> | ||||
Component: | CLI | Assignee: | Lukas Krejci <lkrejci> | ||||
Status: | CLOSED CURRENTRELEASE | QA Contact: | Mike Foley <mfoley> | ||||
Severity: | urgent | Docs Contact: | |||||
Priority: | high | ||||||
Version: | 3.0.0 Beta1 | CC: | gcooper, hrupp, lkrejci | ||||
Target Milestone: | --- | ||||||
Target Release: | JON 3.0.0 | ||||||
Hardware: | x86_64 | ||||||
OS: | Linux | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | |||||||
: | 786976 (view as bug list) | Environment: | |||||
Last Closed: | 2012-02-07 19:25:20 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | |||||||
Bug Blocks: | 717392, 734807, 786976 | ||||||
Attachments: |
|
Description
Nabeel Saad
2011-10-04 17:59:20 UTC
regression I just reproduced this bug with a simple script. // inventory.js rhq.login('rhqadmin', 'rhqadmin'); var resources = ResourceManager.findResourcesByCriteria(ResourceCriteria()); println('There are ' + resources.size() + ' resources in inventory'); // end script I get the same NPE when I try running with rhq-cli.sh -f inventory.js. This is a major regression. It looks like it prevents users from running script files in batch or non-interactive mode. Fortunately there is somewhat of a work around. You can execute script files from the interactive shell using the exec command. If I log into the interactive shell, I can run the script file from there. Here is an example to illustrate: bash-4.1$ ./rhq-cli.sh RHQ - RHQ Enterprise Remote CLI 4.1.0-SNAPSHOT unconnected$ login rhqadmin rhqadmin Remote server version is: 4.1.0-SNAPSHOT (3177dd2) Login successful rhqadmin@localhost:7080$ exec -f inventory.js Remote server version is: 4.1.0-SNAPSHOT (3177dd2) There are 200 resources in inventory Hello John, Glad you were able to reproduce this so easily. The workaround is good to know; however, it still doesn't allow for running the script via an "automated" process, can you? i.e you can't have an external script call a CLI JS script... I'm trying to find a way around that because in the next couple of weeks I will NEED this functionality for an important demo... Out of the things that you did, I would have expected that you wouldn't have to do: login rhqadmin rhqadmin Given that your script had that line in the JS file. I think that is the main problem. If you try to do the line: exec -f inventory.js before the login, it fails with the same NPE stack. I guess in the meantime, I could do the following to get things working the way I want it to: (echo "login rhqadmin rhqadmin"; echo "exec -f /opt/CLI/autoImport.js"; echo "quit") | ./rhq-cli.sh Cheers. Nabeel In org.rhq.enterprise.client.ClientMain#executePromptCommand at boolean result = commands.get("exec").execute(this, args); this is supposed to be a ClientMain that has a remoteClient already set. This is not true, which later makes the cli go to org.rhq.enterprise.client.commands.ScriptCommand#initBindings public void initBindings(ClientMain client) { if (jsEngine == null) { bindings = new StandardBindings(client.getPrintWriter(), client.getRemoteClient()); and then NPE in org.rhq.bindings.StandardBindings#StandardBindings when trying to get the managers public StandardBindings(PrintWriter output, RhqFacade rhqFacade) { PageControl pc = new PageControl(); pc.setPageNumber(-1); managers = rhqFacade.getManagers(); commit 909e4f54d6d932c1c9168bce97f6a9cad42b33a2 Author: Lukas Krejci <lkrejci> Date: Tue Oct 11 17:33:19 2011 +0200 BZ 743379 - Make sure to initialize the script engine with as much bindings as possible before the user logs in (and add the rest when logged in). verified RHQ 10/13 build. changing status of VERIFIED BZs for JON 2.4.2 and JON 3.0 to CLOSED/CURRENTRELEASE Setting Target Release correctly |