This recipe shows how to install JBoss EAP as a service and allow it to start at boot time.
In order to do that, you need to use some script files which are contained within the server distribution and, for Windows users, download some extra native files. The next two sections discuss about it:
In order to start the JBoss EAP as service using a Linux distribution you can use a script named jboss-as-standalone.sh which can be located under the JBOSS_HOME/bin/init.d folder
At first edit the first 20 rows of it to specify the path where the application server is installed (JBOSS_HOME), the system user that will have the ownership of the JVM process (JBOSS_USER). We need also to specify, within the script comments, a set of boot levels to be used by the chkconfig utility tool:
Once completed the highlighted changes, as root user copy this shell script to the location where your Linux distro contains init scripts, renaming to a simpler name such as €œjboss€:
In this example we are using Linux Centos which is a repackaged version of Red Hat Enterprise Linux.
Next, still as root, you need to set execute permissions for this file:
Next, we will use the chkconfig command to install the EAP as a service: the first command will add the jboss shell script to the chkconfig list:
The second one, sets the boot levels where the service will be started:
In order to test that the service starts correctly issue:
And here’s the corresponding service stopping:
At the time of writing installing the EAP 6 as service requires a bit of hacking since the server distribution does not ship with the required libraries and service configuration files. In order to do that, we will need using some libraries from the Apache Daemon project (http://commons.apache.org/proper/commons-daemon/index.html) which allows wrapping the JVM process from a common entry point. So, start by downloading the Common Daemon zip library from
Unzip the library commons-daemon-1.0.15-bin.zip and copy the file commons-daemon-1.0.15.jar into the folder JBOSS_HOME\modules\native\sbin (You need to create this folder in your distribution). Besides the Daemon Java library, you need also a native library in order to install it as a Service. You can get it at: http://www.apache.org/dist/commons/daemon/binaries/windows/
Unpack the file commons-daemon-1.0.15-bin-windows.zip and copy the file prunsrv.exe which is appropriate for your system architecture (32 bit / 64 bit). Finally, as last step, you need to include the files service.bat and service.conf.bat which are used to install the service and configure its properties. An example configuration is available on the author repository at: https://github.com/fmarchioni/ascookbook/tree/master/JBossEAP).
Great! We€™ve finished hacking and your JBOSS_HOME\modules\native\sbin should look like this:
Now install the service by launching the service.bat script as follows:
You can now start/stop the application server using the Windows Process Manager tool:
Installing the JBoss AS 7 platform as a Windows service requires a different approach. This is documented in the following tutorial.
Enterprise Application Servers Cookbook
This excerpt has been taken from the Enterprise Application Servers Cookbook which is a practical, easy to understand guide that discusses about the three major industry Application Servers in the Java EE market: Oracle Weblogic, JBoss EAP and IBM Websphere. Including 600 pages of handy recipes, this book promises to teach you all about the three application servers using an enjoyable style and including detailed comparison between them.