Thursday, April 28, 2011

JBoss6.0 Bug - TimerService

I was trying to upgrade from JBoss 4.2.2 GA to JBoss6.0.0.Final and got this issue in TimerService.
Found the issue in the source code of JBoss and intimated to JBoss support team.


1. Automatically take heapdump on OOM (out-of-memory) error
Set following JVM options: -XX:+HeapDumpOnOutOfMemoryError XX:HeapDumpPath=<FILE-PATH>

2. Manually take heapdump
<JAVA_HOME>/bin/jmap -dump:live,format=b,file=heapdump.hprof <pid-of-java-process>

Download and use MAT (Memory analyzer Tool) to analyze the heapdump.

Migrate JBoss db from Hypersonic to MySql

Quick steps to do this migration:

Versions: JBoss 4.2.2, MySql 5.0.77

1. Copy MySql drive jar to to <JBOSS_HOME>/server/default/lib directory. (For example, mysql-connector-java-5.0.5-bin.jar)

2. Remove <JBOSS_HOME>/server/default/deploy/hsqldb-ds.xml

3. Copy <JBOSS_HOME>/docs/examples/jca/mysql-ds.xml to <JBOSS_HOME>/server/default/deploy. Update JNDI-Name, Connection-URL, User-Name and Password tags in this file to your application specific values.
For example, In my case, the values were -
('createDatabaseIfNotExist' flag will create 'jbossdb' automatically if it doesn't exist)

4. Update tags 'datasource-mapping' and 'fk-constraint' in <JBOSS_HOME>/server/default/conf/standardjbosscmp-jdbc.xml to following values:

5. Add following 'application-policy' in <JBOSS_HOME>/server/default/conf/login-config.xml
<application-policy name = "MySqlDbRealm">
<login-module code = "" flag = "required">
<module-option name = "principal">your_user</module-option>
<module-option name = "userName">your_user</module-option>
<module-option name ="password">your_pass</module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=DefaultDS</module-option>

6. In <JBOSS_HOME>/server/default/deploy/jms directory, replace file hsql-jdbc2-service.xml by file <JBOSS_HOME>/docs/examples/jms/mysql-jdbc2-service.xml and change the one mention of MySqlDS to DefaultDS.

7. Rename hsqldb-jdbc-state-service.xml to mysql-jdbc-state-service.xml. (No changes)

This post should help for given versions of the software for sure.