With JBoss AS 7 Command Line Interface (CLI) has been introduced. Using CLI one can connect to the AS7 domain controller as well as to a standalone server and execute management operations like deploy, undeploy applications, create/delete queue, create/delete topics, create/delete data sources etc. In earlier release JBoss used to have twiddle commands however the changes made it used to not be persistence if we restart the servers all the changes made using twiddle commands would not be taken which is not in the case of CLI.

Hence in this article we would be concentrating on the first step to use any of the features of CLI which is to connect to JBoss servers in domain and standalone mode. You should run all these commands from the /bin folder.

Connect command

You can either connect to the default address which is localhost:9999 and if you want to connect using a specified IP address and port.

1) Connect to default host & port

Following is the command to first start the jboss-admin script and then connect to the default host and port which is localhost:9999

 bin]$ ./jboss-admin.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect
The controller is not available at localhost:9999
[standalone@localhost:9999 /]

You can even directly given the connect command when you are running the script as shown below

bin]$ ./jboss-admin.sh --connect
Connected to standalone controller at localhost:9999
[standalone@localhost:9999 /]

2) Connect to custom host & port

Following is the command to first start the jboss-admin script and then connect to the custom host and port, you can do this which is useful for remote deployments etc.

./jboss-admin.sh
connect [host][:port]

Example:

 bin]$ ./jboss-admin.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect 10.10.10.10:9999
Connected to standalone controller at 10.10.10.10:9999
[standalone@10.10.10.10:9999 /]

You can even directly given the connect command with the host and port when you are running the script as shown below

./jboss-admin.sh --connect controller=[host][:port]

example:

./jboss-admin.sh --connect controller=10.10.10.10:9999
Connected to standalone controller at 10.10.10.10:9999
[standalone@10.10.10.10:9999 /]

3) Connect directly when running jboss-admin.sh/bat

You can also directly add the above connection commands in the jboss-admin.sh or bat so when you call the script it would directly connect to JBoss, which can be done as below.

eval "$JAVA" $JAVA_OPTS -jar "$JBOSS_HOME/jboss-modules.jar" -logmodule "org.jboss.logmanager" -mp "$JBOSS_HOME/modules" org.jboss.as.cli '--connect controller=10.10.10.10:9999"$@"'

4) Connect using username & password

If you had noticed that we have not given any credentials to connect with the JBoss servers which I believe would be not a good approach for production environment or else anyone can make the changes and we dont want that, hence to secure the connecting part we would have to modify two files which in standalone mode and two file in domain mode as shown below

Standalone mode

  1. /standalone/configuration/mgmt-users.properties
  2. Uncomment the username and password by default its admin for both

  3. /standalone/configuration/standalone.xml
  4. Then add security-realm=”PropertiesMgmtSecurityRealm” in native-interface which can be used to secure the management interfaces for the port 9999 as shown below

                <native-interface interface="management" port="9999" security-realm="PropertiesMgmtSecurityRealm"/>
    

Domain mode

  1. /domain/configuration/mgmt-users.properties
  2. Uncomment the username and password by default its admin for both

  3. /domain/configuration/host.xml
  4. Then add security-realm=”PropertiesMgmtSecurityRealm” in native-interface which can be used to secure the management interfaces for the port 9999 as shown below

                <native-interface interface="management" port="9999" security-realm="PropertiesMgmtSecurityRealm"/>
    

Once this is done you can run the any of the above commands which would then ask for the username and password to connect.

Example:

bin]$ ./jboss-admin.sh --connect
Authenticating against security realm: localhost.localdomain
Username:admin
Password:*****
Connected to standalone controller at localhost:9999
[standalone@localhost:9999 /]
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.