This short tutorial explains all the things you need to know about the startup process of JBoss AS, how to inject system properties in the application server and how to trace the logs of the start up activities.
How to start JBoss EAP 6 and WildFly
You can start the application server in standalone mode using the following command from $JBOSS_HOME/bin:
Windows users can use the equivalent command:
You can bind the application server public interfaces to a different IP address using:
$ standalone.sh -Djboss.bind.address=192.168.0.1
On the other hand, you can bind the application server management interfaces to a different IP address using:
$ standalone.sh -Djboss.bind.address.management=192.168.0.1
The above commands will start the application server using the default (standalone.xml) configuration file. If you want to use an alternate configuration, you have to include the -c parameter. In the following example, we are starting the application server in standalone mode using the standalone-ha.xml (clustering) configuration:
$ standalone.sh -c standalone-ha.xml
If you want to specify an offset for the server, then you can use the property jboss.socket.binding.port-offset as follows:
$ standalone.sh -Djboss.socket.binding.port-offset=100
In Domain mode, you can start the application server Domain as follows:
This will pickup the host.xml and domain.xml files from the domain/configuration folder. As an alternative, you can specify a different set of files on the command line:
$ domain.sh -domain-config=mydomain.xml -hostconfig=myhost.xml
Setting System Properties at Startup in WildFly and EAP 6
You have a wide set of options for setting System Properties in the most recent version of the aplication server. You can use the standard -D option, for example:
$ standalone.sh -Dmyproperty=value
You can also use the -P parameter to point to an URL where properties are defined. For example:
$ standalone.sh -P http://somehost/some-location.properties
Finally, Properties can be set via the CLI as in the following example:
[standalone@host:9990 /] /system-property=foo:add(value=bar)
How to start JBoss AS 5 and older versions
Starting the application server is just a matter of launching the start.cmd (Windows) or start.sh (Unix) script.
You can however customize the server startup using several parameters:
The option -b can be used to bind all server services to an IP Address.
run.sh -b 192.168.10.1 # Bind the server on the IP Address 192.168.10.1 run.sh -b 0.0.0.0 # Bind the server on all network interfaces
The option -c can be used to choose which server configuration will be started. If not used the "default" will be chosen.
run.sh -c all # Starts the "all" server configuration
The options -B can be used to add an extra library to the front bootclasspath
This is equivalento to dropping a jar library into $JBOSS_HOME/lib.
The options -L can be used to add an extra library to the loaders classpath
This is equivalent to dropping a jar library into $JBOSS_HOME/common/lib.
You can set a system property through the
-D<name>=<value> option. You can also use the -P option to load the properties from a file.
Create a file named test.properties:
launch JBoss AS with:
run.cmd -P test.properties
Applications using JGroups library might benefit from the -m and -u option.
-m sets the UDP multicast port; only used by JGroups. -u sets the UDP multicast address
Setting JBoss AS 4/5/6 Server properties using the Properties Service
One cool way to add a list of System properties to JBoss is the Properties MBean Service.
In the deployment folder look for "properties-service.xml". (if you don't have it in your release you can create it at any time) :
Now add your properties either in the URLList Attribute or in the Properties Attribute:
<server> <mbean code="org.jboss.varia.property.SystemPropertiesService" name="jboss:type=Service,name=SystemProperties"> <attribute name="URLList"> http://somehost/some-location.properties, ./conf/somelocal.properties </attribute> <attribute name="Properties"> property1=This is the value of my property property2=This is the value of my other property </attribute> </server>
As you can see the The "URLList" is a comma-separated list of URL strings from which to load properties file-formatted content while the "Properties" is a specification of multiple property name=value pairs. Now you can access your properties with standard:
Logging the startup process
JBoss uses the Log4jService (in JBoss AS 5.x and earlier) or the LoggingService (in JBoss AS 6.x and later) to configure logging.
However this service is not configured until after the bootstrap phase.
During the bootstrap the microkernel logs into log/boot.log using the configuration defined in log4j.properties (in 5.x and earlier) or logging.properties (in 6.x and later) contained in $JBOSS_HOME/bin/run.jar.
If you want to customize the boot loggin you have basically two options:
- Change the configuration inside run.jar
- Use a system property to reference an outside configuration file.
The simplest strategy is to un-jar $JBOSS_HOME/bin/run.jar, change the appropriate properties file and re-jar. (We suggest you using the Open Source archiving software 7-zip which does a good job at editing files inside of archives).
Alternatively, you can also specify the boot log configuration at the command line, instead of editing run.bat/run.sh, for example:
or for the release 6.x :
How to start JBoss as a service.
See the following article: Run JBoss as Service HowTo