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
http://jbossas.jboss.org/downloads/
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:
http://www.davidghedini.com/pg/entry/install_jboss_7_on_centos
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
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
JENKINS_AJP_PORT="7009"
JENKINS_PORT="7070"
Add user in JBoss
cd /usr/share/jboss-as/bin
./add-user.sh
./add-user.sh
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'
Done
You can access JBoss in local address: http://localhost:7070/
Or by using port forwarding http://localhost:7000/ and http://localhost:7009/
Error:
jboss Context initialization failed: java.lang.OutOfMemoryError: PermGen space
Solution:
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
Open /usr/share/jboss-as/standalone/configuration/standalone.xml
Find datasources and add datasource section for Oracle:
<datasources>
<datasource jndi-name="java:jboss/yourDataSourceName" pool-name="yourDataSourceName" enabled="true">
<connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</connection-url>
<driver>com.oracle</driver>
<pool>
<min-pool-size>3</min-pool-size>
<max-pool-size>5</max-pool-size>
</pool>
<security>
<user-name>oracle_user</user-name>
<password>oracle_password</password>
</security>
<validation>
<exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
</validation>
<timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
</datasource>
<drivers>
<driver name="com.oracle" module="com.oracle">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
</drivers>
</datasources>
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">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
Restart JBoss:
/etc/init.d/jboss restart
You can also check your data sources in JBoss admin console.
Done.
Solving errors
Error:
jboss Context initialization failed: java.lang.OutOfMemoryError: PermGen space
Solution:
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"
/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:
<datasources>
<datasource jndi-name="java:jboss/yourDataSourceName" pool-name="yourDataSourceName" enabled="true">
<connection-url>jdbc:oracle:thin:@127.0.0.1:1521:xe</connection-url>
<driver>com.oracle</driver>
<pool>
<min-pool-size>3</min-pool-size>
<max-pool-size>5</max-pool-size>
</pool>
<security>
<user-name>oracle_user</user-name>
<password>oracle_password</password>
</security>
<validation>
<exception-sorter class-name="org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter"/>
</validation>
<timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>5</idle-timeout-minutes>
</timeout>
</datasource>
<drivers>
<driver name="com.oracle" module="com.oracle">
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
</driver>
</drivers>
</datasources>
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">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
Restart JBoss:
/etc/init.d/jboss restart
You can also check your data sources in JBoss admin console.
Done.
No comments:
Post a Comment