Why some CLI commands can't be used by JAVA code?
Issue
With Java code + jboss-cli-client.jar(from ${EAP7}/bin/client/) to manipulate EAP 7.0.x domain mode as below:
public class TestCLI {
public static void main(String[] args) throws CommandLineException, IOException{
String host = "127.0.0.1";
int port = 9990; //or 9999
String user = "abc";
char[] password = "defghiLMN12#".toCharArray();
CommandContext ctx = CommandContextFactory.getInstance().newCommandContext(user,password);
ctx.connectController(host, port);
ModelControllerClient client = ctx.getModelControllerClient();
ctx.handle("ls"); // This command works fine
ctx.handle("jms-queue add --profile=full-ha --queue-address=mQ --entries=[queue/mQ jms/queue/mQ java:jboss/exported/jms/queue/mQ]"); //This command failed to work.
...
Error shows:
Exception in thread "main" org.jboss.as.cli.CommandLineException: Unexpected command 'jms-queue add --profile=full-ha --queue-address=mQ --entries=[queue/mQ jms/queue/mQ java:jboss/exported/jms/queue/mQ]'. Type 'help --commands' for the list of supported commands.
at org.jboss.as.cli.impl.CommandContextImpl.handle(CommandContextImpl.java:779)
at com.test1.TestCLI.main(TestCLI.java:xx)
However the commands all worked fine in CLI console.
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
