Tuesday, August 26, 2014

Install JBoss in CentOS Linux

How to install JBoss in CentOS Linux

Install Oracle Java
JBoss requires original Oracle Sun Java or compatible VM. As first step, Install Oracle Java.

Download JBoss 7.1.1 Final
wget http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.zip

Install JBoss
I followed this step by step how to:

Changes against above doc

Java settings moved from bash_profile to bashrc to let it work after sudo su

We have original Java from Oracle, therefore I edited /etc/init.d/jboss and commented Java setup:
# Load Java configuration.
# [ -r /etc/java/java.conf ] && . /etc/java/java.conf
# export JAVA_HOME

In /etc/init.d/jboss change setting for chkconfig (no hyphen):
chkconfig: 234 80 20

Additional setup commands:
mkdir -p /var/run/jboss-as/ /etc/jboss-as/ /var/log/jboss-as/
chown jboss.jboss /var/run/jboss-as/ /etc/jboss-as/ /var/log/jboss-as/
cp /usr/share/jboss-as/bin/init.d/jboss-as.conf /etc/jboss-as/jboss-as.conf

Note for Jenkins and Oracle
To prevent interference with Jenkins and Oracle XE ports I did following changes:
In Jenkins I changed AJP port to 7009.
In Jenkins I changed web port to 7070.
In Oracle XE I changed web admin port to 6060.

Change in /etc/sysconfig/jenkins

Add user in JBoss
cd /usr/share/jboss-as/bin
login: jboss
pass: jboss_admin_password
Added user 'jboss' to file '/usr/share/jboss-as/standalone/configuration/mgmt-users.properties'
Added user 'jboss' to file '/usr/share/jboss-as/domain/configuration/mgmt-users.properties'

You can access JBoss in local address: http://localhost:7070/
Or by using port forwarding http://localhost:7000/ and http://localhost:7009/

Solving errors

jboss Context initialization failed: java.lang.OutOfMemoryError: PermGen space

Open file /usr/share/jboss-as/bin/standalone.conf
Insert following line at the beginning of this file:

export JAVA_OPTS="-server -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xms256m -Xmx1g -XX:PermSize=64M -XX:MaxPermSize=1g"

This will change settings for garbage collector, heap size and perm size. You can adjust memory settings as you need. After configuration, save file, restart jboss:

/etc/init.d/jboss restart

Data Source configuration

Open /usr/share/jboss-as/standalone/configuration/standalone.xml

Find datasources and add datasource section for Oracle:

                <datasource jndi-name="java:jboss/yourDataSourceName" pool-name="yourDataSourceName" enabled="true">
                        <exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
                    <driver name="com.oracle" module="com.oracle">

Add Oracle JARs to JBoss

mkdir -p /usr/share/jboss-as/modules/com/oracle/main
cp /u01/app/oracle/product/11.2.0/xe/jdbc/lib/*.jar /usr/share/jboss-as/modules/com/oracle/main
chown -R jboss.jboss /usr/share/jboss-as/modules/com/oracle

Create modules configuration

Create file /usr/share/jboss-as/modules/com/oracle/main/module.xml as follows:

<module xmlns="urn:jboss:module:1.0" name="com.oracle">
        <resource-root path="ojdbc6.jar"/>
        <module name="javax.api"/>

Restart JBoss:

/etc/init.d/jboss restart

You can also check your data sources in JBoss admin console.


No comments: