Bug 977426

Summary: jboss-cli.sh throws NullPointerException while not connected and in batch mode
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Thomas Hauser <thauser>
Component: CLIAssignee: Alexey Loubyansky <olubyans>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: brian.stansberry, cdewolf, myarboro, pkremens
Target Milestone: ER1   
Target Release: EAP 6.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Attempting to add a command to a batch with the `jboss-cli` tool when it was disconnected from the server would cause the `jboss-cli` to exit. This has been corrected. Attempting to add commands to a batch when disconnected from a server will now result in the following error message being displayed to the user: ---- Command is not supported or unavailable in the current context: Failed to load operation description: not connected ----
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-15 16:23:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Thomas Hauser 2013-06-24 14:08:26 UTC
Description of problem:
When the jboss-cli.sh (and by extension, the CommandContext API in java) is given certain commands while not connected to the client, an unhandled NPE is thrown from org.jboss.as.cli.handlers.GenericTypeOperationHandler.getOperationDescription(GenericTypeOperationHandler.java:886)


Version-Release number of selected component (if applicable):
7.2.0.Final-redhat-8

How reproducible:
Always.

Steps to Reproduce:
1) Start the server in standalone or domain mode. 

2) Run jboss-cli.sh, but do not connect.
./jboss-cli.sh

3) Enter batch mode in jboss-cli.sh
batch

4) Run the following command:
Standalone:
data-source add --name=test --connection-url=test --jndi-name=java:/ --driver-name=h2
Domain:
data-source add --profile=full --name=test --connection-url=test --jndi-name=java:/ --driver-name=h2

Stacktrace here: http://pastebin.test.redhat.com/148807

Actual results:
jboss-cli.sh crashes with an NPE.

Expected results:
The command should either be added to the batch, or give a message about the command not being able to be run without being connected (running the same command while not in batch mode gives a nice error message, for example.)

Additional info:
See also: https://issues.jboss.org/browse/WFLY-1512

Comment 3 Petr Kremensky 2013-09-18 12:35:53 UTC
Verified on EAP 6.2.0.ER2. 
Adding the command to batch while disconnected now gives the error massage:

Failed to add to batch '${commnad}': Command is not supported or unavailable in the current context: Failed to load operation description: not connected