Jboss Admin Tutorial: Controlling the Life-Cycle of JBoss AS

5. Controlling the Life-Cycle of JBoss AS

5.1. Starting JBoss AS

  • To start JBoss, run $JBOSS_HOME/bin/run.sh on Unix/Linux and %JBOSS_HOME%\run.bat on Windows
  • The script figures out JBOSS_HOME by itself - though it does not hurt to have it pre-specified as discussed already
  • By default, this script runs the default configuration set

    • Alternative configuration set can be specified: ./run.sh -c <configuration_set_name>
  • By default, this script binds JBoss AS to 127.0.0.1 (for security reasons) making it inaccessible from the outside world

    • To bind JBoss to a specific address, execute: ./run.sh -b 10.1.2.3 or ./run.sh --host=10.1.2.3
    • To bind JBoss to all addresses, execute: ./run.sh -b 0.0.0.0 or ./run.sh --host=0.0.0.0
  • To start JBoss as a system service

    • On Unix/Linux, use a script like jboss_init_redhat.sh

      • Copy (or symbolically link) this script to /etc/init.d/jboss
      • Edit the script as needed (to specify user, IP, and file paths)
      • Add #chkconfig: 3 80 20 and #description: JBoss to this script
      • Run chkconfig --add jboss
    • On Windows use JavaService (http://forge.objectweb.org/projects/javaservice/), which comes with an installation script for JBoss
usage: run.bat [options]

options:
-h, --help                    Show this help message
-V, --version                 Show version information
--                            Stop processing options
-D<name>[=<value>]            Set a system property
-d, --bootdir=<dir>           Set the boot patch directory; Must be absolute or url
-p, --patchdir=<dir>          Set the patch directory; Must be absolute or url
-n, --netboot=<url>           Boot from net with the given url as base
-c, --configuration=<name>    Set the server configuration name
-B, --bootlib=<filename>      Add an extra library to the front bootclasspath
-L, --library=<filename>      Add an extra library to the loaders classpath
-C, --classpath=<url>         Add an extra url to the loaders classpath
-P, --properties=<url>        Load system properties from the given url
-b, --host=<host or ip>       Bind address for all JBoss services
-g, --partition=<name>        HA Partition name (default=DefaultDomain)
-m, --mcast_port=<ip>         UDP multicast port; only used by JGroups
-u, --udp=<ip>                UDP multicast address
-l, --log=<log4j|jdk>         Specify the logger plugin type
[Note]Note

On Unix/Linux, run.sh (and shutdown.sh) source JVM/runtime options from run.conf file whereas on Windows run.bat specifies those options internally.

5.2. Verifying JBoss AS Startup

  • JBoss has successfully started when in its console window you can see a line like this:
13:26:33,625 INFO  [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 2m:20s:844ms
  • If you see any exception traces, then there was a problem starting one or more of the JBoss services. Examine the error messages before continuing. A common problem is a port conflict: another server (possibly another instance of JBoss AS itself) is running on one or more of the required JBoss AS ports.
  • Point your browser to http://localhost:8080/status to verify the server startup.
images/JBoss_Status.png

5.3. Stopping JBoss AS

  • If started in foreground using the run script, simply hit CTRL+C
  • If running in the background as an OS service, stop it just like any other OS service

    • /etc/init.d/jboss stop (on UNIX/Linux)
    • kill -TERM <jboss-pid> (on UNIX/Linux)
    • NET STOP JBoss (on Windows)
  • Use the shutdown script (remote shutdown): $JBOSS_HOME/bin/shutdown.sh -S (shutdown.bat on Windows)
A JMX client to shutdown (exit or halt) a remote JBoss server.

usage: shutdown [options] <operation>

options:
-h, --help                Show this help message (default)
-D<name>[=<value>]        Set a system property
--                        Stop processing options
-s, --server=<url>        Specify the JNDI URL of the remote server
-n, --serverName=<url>    Specify the JMX name of the ServerImpl
-a, --adapter=<name>      Specify JNDI name of the MBeanServerConnection to use
-u, --user=<name>         Specify the username for authentication
-p, --password=<name>     Specify the password for authentication

operations:
-S, --shutdown            Shutdown the server
-e, --exit=<code>         Force the VM to exit with a status code
-H, --halt=<code>         Force the VM to halt with a status code

To shutdown a remote JBoss AS instance, use: ./shutdown.sh -s jnp://remoteHostOrIP:1099 -S Remote instance’s IP address and port are specified by its Naming service configured in ${jboss.server.config.url}/jboss-service.xml

5.4. Starting From a Remote Server

  • JBoss can load itself from a network server using run script’s -netboot=<url> option
  • Result: jboss.home.dir=<url>

    • Everything resolved relative to home URL
  • NetBoot requires run.jar on the client side, and a web server with support for PROPFIND WebDAV command

    • JBoss AS itself can serve this role
    • Use an Ant script to set this up
  • To boot JBoss AS from a remote server, you would execute something like this: ./run.sh --netboot=http://192.168.0.1:8080/jboss/