JBoss EAP 6 as RHEL 7 service

Not long ago, Red Hat made available 7.0 GA version of Red Hat Enterprise Linux OS.

One of the most important changes in RHEL 7 was managing services, wich in previous versions was managed with Upstart (based on System V) but now managing services is made with systemd.

The JBoss EAP 6 documentation only explain how to configure JBoss as a service based on System V, in this post I’ll show step by step how do it in systemd.

Another change is about firewall, RHEL 7 comes with firewalld (also keeps iptables, but it is preferred to use firewalld), so I’ll explain how to configure firewalld to access JBoss.

Let’s go:

First let’s create JBoss system user

 # useradd -r -u 400 -s /sbin/nologin -d /usr/share/jboss-as jboss

When installing EAP we can choose to do it by jar or by zip. Take a look this post: Instalando JBoss EAP 6.2. It’s preferred to install in this path: /usr/share/jboss-as, where RPM package and documentation advise installing. This path must be accessible to jboss user, so let’s give the appropiate permissions:

# chown -R jboss:jboss /usr/share/jboss-as

Ok. Now let’s create configuration folder where we’ll put the config file wich defines environment variables for service script. Also logs directory and PID file directory

# mkdir /etc/jboss-as
# cat > /etc/jboss-as/jboss-as.conf <<EOF
> ## Process user
> JBOSS_USER=jboss
> ## Waiting time for returning control to SHELL, it depends upon how many applications/services that will be deployed
> ## Waiting time for returning control to SHELL, it depends upon how many applications/services that will be undeployed
> ## Log directory and file.
> JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log
> ## JBoss EAP home directory
> JBOSS_HOME=/usr/share/jboss-as/jboss-eap-6.X
# mkdir /var/log/jboss-as
# mkdir /var/run/jboss-as
# chown -R jboss:jboss /var/log/jboss-as
# chown -R jboss:jboss /var/run/jboss-as

And only need to create the service file:

 # cat > /etc/systemd/system/jboss-as-standalone.service <<EOF
> [Unit]
> Description=Jboss Application Server
> After=syslog.target network.target
> [Service]
> Type=forking
> ExecStart=/usr/share/jboss-as/bin/init.d/jboss-as-standalone.sh start
> ExecStop=/usr/share/jboss-as/bin/init.d/jboss-as-standalone.sh stop
> [Install]
> WantedBy=multi-user.target

Reload systemd daemon,start EAP service, verify their state and enable it:

# systemctl daemon-reload
# systemctl start jboss-as-standalone.service
# systemctl status jboss-as-standalone.service
# systemctl enable jboss-as-standalone.service

Well, now just get into the awesome world of FirewallD, but it will be in other post (I hope that’s not taking so much), let’s concentrate to create and anable a basic service for EAP. First I’ll create service, after that I’ll activate it, I’ll enable it persistent, and last I’ll verify service in runtime and persistent(assuming we’re working on public zone):

# cat > /etc/firewalld/services/jboss-as-standalone.xml
> <?xml version="1.0" encoding="utf-8"?>
> <service version="1.0">
>      <short>jboss-as-standalone</short>
>      <port port="8080" protocol="tcp"/>
>      <port port="8443" protocol="udp"/>
>      <port port="8009" protocol="tcp"/>
>      <port port="4447" protocol="tcp"/>
>      <port port="9990" protocol="udp"/>
>      <port port="9999" protocol="tcp"/>
> </service>
# firewall-cmd --zone=public --add-service=jboss-as-standalone
# firewall-cmd --permanent --zone=public --add-service=jboss-as-standalone
# firewall-cmd --zone=public --list-services
# firewall-cmd --permanent --zone=public --list-services

Ready, EAP is working as a service on RHEL 7.

 See you soon…

2 thoughts on “JBoss EAP 6 as RHEL 7 service

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.