Eric, welcome to the forums.
CLI (Command Line Interface) is a tool to facilitate invoking management operations against a server. It's an alternative to the web console. When you say you want to use the CLI in your application, do you really mean you want to use that CLI (the command line interface) or do you mean that you want to invoke management operations against the server from your application, just like the CLI does?
Hi, sorry for the confusion. I meant that I want to invoke management operations against the server from my application.
Digging down into the source code of jboss-as-cli-7.2.0.Final.jar, I see that there are two Namespace enums defined CLI_1_0("urn:jboss:cli:1.0") and CLI_1_1("urn:jboss:cli:1.1"). However, the namespace version in the actual jboss-cli.xml document is urn:jboss:cli:1.2. jboss-as-cli-7.2.0.Final.jar, which I fetch from the maven repository, is not exactly the same version that is running in the appserver, which is jboss-as-cli-7.2.0.Final-redhat-8.jar and contains the correct namespace enum.
So what's up with the discrepency?
jboss-as-cli-7.2.0.Final.jar is a jar from JBoss AS 7.2.0.Final.
jboss-as-cli-7.2.0.Final-redhat-8.jar is a jar from the enterprise edition - JBoss EAP 6.1.0, which is way newer than JBoss AS 7.2.0.Final and contains a newer version of the XML schema (urn:jboss:cli:1.2). And you're trying to use the old JAR with the new schema.
I suppose you are running that code from within JBoss EAP? If yes, you can just add a dependency to the org.jboss.as.cli module for your deployment (either through MANIFEST.MF or jboss-deployment-structure.xml).. then, the jboss-as-cli-7.2.0.Final-redhat-8.jar will be on the classpath for your application and you don't need to add any dependency added through maven or whatever else you are using. If you want to add the CLI dependency through maven, you need to depend on jboss-as-cli-7.2.0.Final-redhat-8.jar (which is not available in public repositories, so you need to use the zipped repo distributed with EAP).
Yep, realized that I was using 7.2.0.Final. Changed the version to 7.2.0.Final-redhat-8 and now it works. Thanks.
I tried your suggestion of using jboss-deployment-structure.xml to specify org.jboss.as.cli as a module and exclude all dependencies. I got the following error, do you know why? I'm using Wildfly 10.0.0.
CliInitializationException : org.jboss.as.cli.CliInitializationException: Failed to load org.jboss.as.cli.impl.CommandContextFactoryImpl