Installing JBoss EAP 6 as a service

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

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:

 

 Linux users

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:

#!/bin/sh

# JBoss standalone control script

#

# chkconfig: 2345 80 20

# description: JBoss AS Standalone

# processname: standalone

# pidfile: /var/run/jboss-as/jboss-as-standalone.pid

# config: /etc/jboss-as/jboss-as.conf

 

# Source function library.

. /etc/init.d/functions

 

# Load Java configuration.

[ -r /etc/java/java.conf ] && . /etc/java/java.conf

export JAVA_HOME

 

JBOSS_USER=jboss

export JBOSS_USER

JBOSS_HOME=/usr/share/jboss-eap-6.1

export JBOSS_HOME

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”:

[root@dev2 bin]# cp jboss-as-standalone.sh /etc/init.d/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:

[root@dev2 init.d]# chmod 755 jboss 

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:

[root@dev2 init.d]# chkconfig --add jboss 

The second one, sets the boot levels where the service will be started:

[root@dev2 init.d]# chkconfig --level 2345 jboss on

In order to test that the service starts correctly issue:

service jboss start

And here's the corresponding service stopping:

service jboss stop

Windows users

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

http://commons.apache.org/proper/commons-daemon/download_daemon.cgi

jboss book jboss books jboss eap what is jboss

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/

 jboss book jboss books jboss eap what is jboss

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:

jboss book jboss books jboss eap what is jboss

Now install the service by launching the service.bat script as follows:

C:\jboss-eap-6.1\modules\native\sbin>service.bat install

You can now start/stop the application server using the Windows Process Manager tool:

jboss book jboss books jboss eap what is jboss

 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

jboss book weblogic book websphere bookThis 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.

 

Follow us on Twitter