Currently Being Moderated

StartStopJBoss

VERSION 31

Created on: May 19, 2004 5:52 PM by nrichards - Last Modified:  Nov 13, 2008 12:02 AM by Ian Springer

Starting and Stopping JBoss

 

Before you start

Before running JBoss, you will need to make sure that the JAVA_HOME environment variable points to your installed Java SDK.

 

On UNIX based system (Linux, Solaris, OS X): export JAVA_HOME=/path/to/j2sdk-1.4.2_0

 

On Windows (NT based): right click on My Computer, click on Advanced, click on set Environment Variables. Set JAVA_HOME.

 

You should also add JAVA_HOME/bin to the beginning of your PATH.

 

Starting JBoss from the command line

 

To start JBoss, go the the bin directory of your JBoss install and execute the run script appropriate for your system.  (run.bat for Windows, run.sh for UNIX based systems).   When you run JBoss, you should see output similar to the following:

 

 

[rubik:/tmp/jboss-3.2.3/bin] % ./run.sh 
================================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /tmp/jboss-3.2.3

  JAVA: java

  JAVA_OPTS:  -Dprogram.name=run.sh

  CLASSPATH: /tmp/jboss-3.2.3/bin/run.jar:/lib/tools.jar

================================================================================

17:06:59,351 INFO  [Server] Starting JBoss (MX MicroKernel)...
17:06:59,372 INFO  [Server] Release ID: JBoss [WonderLand] 3.2.3 (build: CVSTag=JBoss_3_2_3 date=200311301445)
17:06:59,471 INFO  [Server] Home Dir: /private/tmp/jboss-3.2.3
17:06:59,475 INFO  [Server] Home URL: file:/private/tmp/jboss-3.2.3/
17:06:59,492 INFO  [Server] Library URL: file:/private/tmp/jboss-3.2.3/lib/
17:06:59,502 INFO  [Server] Patch URL: null
17:06:59,571 INFO  [Server] Server Name: default
... 
17:08:36,251 INFO  [MainDeployer] Deployed package: file:/private/tmp/jboss-3.2.3/server/default/conf/jboss-service.xml
17:08:36,274 INFO  [Server] JBoss (MX MicroKernel) [3.2.3 (build: CVSTag=JBoss_3_2_3 date=200311301445)] Started in 1m:36s:383ms

 

Once the started message appears, JBoss is running and is fully operational.

 

If you want to check if startup and initial deployment was successful without examining the log output, see the page StartupAndDeploymentCheck

 

Starting JBoss in the Background

 

By default, run.sh will start the JBoss java process in the foreground. Though Ctrl-C will kill the JBoss java process, if an external HUP or QUIT signal is sent to the run.sh process, it will kill the run.sh process, but the JBoss process will live on.

 

In JBoss 4.0.5 and later, run.sh provides a new option to launch the JBoss process in the background; this option can be enabled by setting the LAUNCH_JBOSS_IN_BACKGROUND environment variable to a non-empty value, e.g.:

export LAUNCH_JBOSS_IN_BACKGROUND=1 

When this option is enabled, run.sh will launch the JBoss process in the background and then relay any OS signals that are sent to the run.sh process to the JBoss process. This allows you to do something like the following in a jboss init.d script:

start()
{
  export LAUNCH_JBOSS_IN_BACKGROUND=1 
  ./run.sh &
  echo $! >$JBOSS_PIDFILE
}

stop()
{
  # This will kill the run.sh process AND the JBoss java process.
  kill `cat $JBOSS_PIDFILE` 
}  

Note, the background launch option works on Cygwin, in addition to actual UNIX systems.

Stopping JBoss

 

If you launched JBoss from the command line, the easiest way to stop it is to press ctrl-C.  JBoss should begin it's shutdown.  Alternatively, you can invoke the shutdown script in the JBoss bin directory.

 

[rubik:/tmp/jboss-3.2.3/bin] % ./shutdown.sh -S
Shutdown message has been posted to the server.
Server shutdown may take a while - check logfiles for completion

 

There're several ways to shutdown JBoss as explained below. If you want to know what JBoss logs in each situation please visit ShutdownLogs wiki.

 

Stopping JBoss on a remote machine

 

Note that you will use the lower-case -s flag along with the jnp protocol plus address and port of the Naming service specified in conf/jboss-service.xml

 

[rubik:/tmp/jboss-3.2.3/bin] % ./shutdown.sh -s jnp://myremotemachineOrIP:1099
Shutdown message has been posted to the server.
Server shutdown may take a while - check logfiles for completion

 

Stopping JBoss when running multiple JBoss instances using the Service Binding Manager

 

You will again use the lower-case -s flag but you will need to look in your bindings file to find the port of each Naming service.

 

<service-bindings>
   
   <server name="ports-default">
     
      <service-config name="jboss:service=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1098</attribute>
         </delegate-config>
         <binding port="1099" host="${jboss.bind.address}"></binding>
      </service-config>

.
.
.

   <server name="ports-01">

      <service-config name="jboss:service=Naming"
         delegateClass="org.jboss.services.binding.AttributeMappingDelegate"
         >
         <delegate-config portName="Port" hostName="BindAddress">
            <attribute name="RmiPort">1198</attribute>
         </delegate-config>
         <binding port="1199" host="${jboss.bind.address}"></binding>
      </service-config>



[rubik:/tmp/jboss-3.2.3/bin] % ./shutdown.sh -s jnp://localhost:1099
Shutdown message has been posted to the server.
Server shutdown may take a while - check logfiles for completion

 

[rubik:/tmp/jboss-3.2.3/bin] % ./shutdown.sh -s jnp://localhost:1199
Shutdown message has been posted to the server.
Server shutdown may take a while - check logfiles for completion

 

 

Interfaces JBoss binds to

 

Up to JBoss 4.2 the server (HTTP and all services) bound to 0.0.0.0, meaning to all interfaces on the system. Since too many people have not secured internet facing systems this behaviour has been changed since JBoss 4.2.0. JBoss now only binds to 127.0.0.1 by default. You can use the -b parameter with run.sh/run.bat to either bind to the desired IP or 0.0.0.0 if you want the pre 4.2 behaviour back. Make sure you went through the security guideline point by point since there are at least 5+ ways an unsecured JBoss server can be taken over.

 

If bound to 0.0.0.0 clients will receive the hostname to connect to RMI. In this case you can set 'java.rmi.server.hostname=' to send an IP or different hostname to the client.

 

Mysterious Shutdowns

Some users have experienced MysteriousShutdowns with JBoss.  These can be do to many things, such as user intervention, OS signals, programming error.  If you have ruled everything else out, you may want to visit the MysteriousShutdowns wiki to see about further action.

 

Detecting JBoss Status

JBoss comes with TWIDDLE, a simple command line tool that may be used, manually or as part of a script, to indicate whether the server has been started successfully

 

Referenced by:

Average User Rating
(0 ratings)




There are no comments on this article

More Like This

  • Retrieving data ...