8/13/2012

My JBoss AS7 jboss-cli Notes

To start standalone server with the default server config (standalone.xml):
$JBOSS_HOME/bin/standalone.sh


To start standalone server on custom, non-default port numbers, using offset=1, 2, 3, etc (negative offset number is invalid).  When starting with offset 1, you will have http port number 8081 (the default 8080+1), CLI port number 10000 (the default 9999+1), admin console port 9991 (the default 9990+1), etc.
standalone.sh -Djboss.socket.binding.port-offset=1

To start standalone server with a specific server config (just the config file name in $JBOSS_HOME/standalone/configuration directory, do not specify its file path):

standalone.sh -c standalone-full.xml
standalone.sh --server-config=standalone-ha.xml
standalone.sh --server-config standalone-full-ha.xml


To avoid/disable "Press any key to continue..." when running JBoss AS7 commands on Windows:
> set NOPAUSE=true
> standalone
> jboss-cli


To start standalone server in debug mode at default debug port 8787, or at a different port, e.g., 6000:
standalone.sh --debug
standalone.sh -d
standalone.sh -d 6000
standalone.sh --debug 6000


To start domain:
domain.sh


To save the PID from AS process, define the environment variable JBOSS_PIDFILE and LAUNCH_JBOSS_IN_BACKGROUND:
export LAUNCH_JBOSS_IN_BACKGROUND=true
export JBOSS_PIDFILE=$JBOSS_HOME/pid


To stop the default standalone server or domain, with :shutdown operation request (there is no shutdown command):
jboss-cli.sh --connect --command=:shutdown
jboss-cli.sh -c "/:shutdown()"
jboss-cli.sh -c /:shutdown
jboss-cli.sh -c :shutdown


To restart
jboss-cli.sh -c ":shutdown(restart=true)"


To stop the standalone server right now no matter what. If the server is running, it has the same effect as Ctrl-C. If the server is not running, $JBOSS_PIDFILE is not present and so nothing is done.
/bin/kill -9 `cat $JBOSS_PIDFILE`


To exit from the shell started with jboss-cli.sh, use any of the following (Ctrl-D does not work, though):
[standalone@localhost:9999 /] Ctrl-C
[standalone@localhost:9999 /] exit
[standalone@localhost:9999 /] quit
[standalone@localhost:9999 /] q


To list all deployed applications, with either deploy or undeploy command (-l option gives more details about the deployed applications):
jboss-cli.sh -c deploy
jboss-cli.sh -c undeploy

jboss-cli.sh -c "ls deployment"
jboss-cli.sh -c "deploy -l"
jboss-cli.sh -c "undeploy -l"


To deploy an application:
jboss-cli.sh -c "deploy $HOME/tmp/hello.war"


To redeploy (forcefully overwrite any existing deployed app) an app:
jboss-cli.sh -c "deploy --force $HOME/tmp/hello.war"


To undeploy an application:
jboss-cli.sh -c "undeploy hello.war"


To get CLI help info:
jboss-cli.sh help
jboss-cli.sh -c help


To show help info for deploy command:
jboss-cli.sh -c "deploy --help"


To display the version of the current running JBoss AS, along with $JBOSS_HOME, $JAVA_HOME, java.version, os.name, os.version, etc:
jboss-cli.sh -c version


To create a string or primitive JNDI resource. Do not quote the value attribute, otherwise the quote will become part of the content. Also need to escape whitespace.
jboss-cli.sh -c "/subsystem=naming/binding=java\:global\/env\/flag:add(binding-type=simple, type=boolean, value=true)"

jboss-cli.sh -c "/subsystem=naming/binding=java\:global\/env\/text:add(binding-type=simple, type=java.lang.String, value=This\ is\ a\ text\ value.)"


To create an alias for a JNDI resource (java:global/env/condition is an alias for java:global/env/flag):
jboss-cli.sh -c "/subsystem=naming/binding=java\:global\/env\/condition:add(binding-type=lookup, lookup=java\:global\/env\/flag)"


To list server extensions, profiles, subsystems, network interfaces, or socket-binding-groups:
jboss-cli.sh -c "ls subsystem"
jboss-cli.sh -c "ls extension"
jboss-cli.sh -c "ls profile"
jboss-cli.sh -c "ls interface"
jboss-cli.sh -c "ls socket-binding-group"

 
To create a datasource witht the default h2 database: 
data-source add --name=test-ds --jndi-name=java\:jboss\/datasources\/test-ds --driver-name=h2 --connection-url=jdbc\:h2\:mem\:test;DB_CLOSE_DELAY\=-1

data-source enable --name=test-ds


To verify a datasource and check if a connection can be obtained: 
data-source test-connection-in-pool --name=test-ds

To disable a datasource: 
data-source disable --name=test-ds 

To delete a datasource: 
data-source remove --name=test-ds

4 comments:

Comp_x_jsp said...

can I start a host-process on another slave host in a domain mode?

Vinodkumar Bolla said...

The information was very useful.
I have one query that if we start/restart the standalone.sh in background we are not sure how much time it'll take depends on the configuration [ connectors and deployed applications ].
In case of non interactive scripting do we need to keep a sleep to verify the starting of the server ? so that we can continue our operations.

Anna said...

Great and Useful Article.

Online Java Training

Java Online Training India

Java Online Course

Java EE course

Java EE training

Best Recommended books for Spring framework

Java Interview Questions








Java Course in Chennai

Java Online Training India

Oracle Fusion HCM Online Training said...

We are ERPTREE Leading oracle fusion HCM Online Training institute. We are providing online training services since 1999. still we have added more oracle related courses as the technology changes in oracle. 2000+ online courses are available. we all ways achieve our goal in satisfying students in result we have global recognition to our site. we have best faculty for all of our online courses.

From

Oracle Fusion HCM Training