I have spent a lot of time lately trying to create a migration plan for an application currently running on JBoss 4.2.2. Since this application development started a few migration attempts to newer versions of JBoss have been done (see for 5.1) but as it seems each version has different style configuration files and this application is expected to have a long lifetime the work seems a bit futile so in parallel of
migrating to JBoss-7.1.1 I’ve tried to migrate to Tomcat since our use of EJB’s is limited and other MBeans can be refactored in simpler ways. Unlike JBoss, Tomcat configuration seems to be eternal and by all means simpler.

1. The data source

The purpose of the following configurations is to define an JNDI DataSource which can be then used in the application allowing DB configuration to be separated from the application itself.

1.1 JBoss 4.2.2

In JBoss 4.2.2 the datasource was defined in a ${name}-ds.xml in the following format:

<pre lang="xml">
<?xml version="1.0" encoding="UTF-8"??>
<datasources>
    <local-tx-datasource>
        <jndi-name>XOracleDS</jndi-name>
        <connection-url>jdbc:oracle:thin:@localhost:1521:XE</connection-url>
        
        <metadata>
            <type-mapping>Oracle9i</type-mapping>
        </metadata>
    </local-tx-datasource>
</datasources>

The JNDI name will be: java:/XOracleDS.

1.2 JBoss 7.1.1

In JBoss 7.1.1 first a module has to be defined as jboss-7/modules/com/oracle/ojdbc4/main containg the ojdbc14.jar and a module.xml.

<pre lang="xml">
<?xml version="1.0" encoding="UTF-8"??>
<module name="com.oracle.ojdbc4" xmlns="urn:jboss:module:1.1">
    <resources>
        <resource-root path="ojdbc14.jar"></resource-root>
    </resources>
    <dependencies>
        <module name="javax.api"></module>
        <module name="javax.transaction.api"></module>
        <module name="javax.servlet.api" optional="true"></module>
    </dependencies>
</module>

Then the file jboss-7/standalone/configuration/standalone.xml has to be modified. The datasources part should be changed to:

<pre lang="xml">
...
<datasources>
<datasource enabled="true" jndi-name="java:/XOracleDS" pool-name="XOracle" use-java-context="true">
    <connection-url>jdbc:oracle:thin:@localhost:1521:XE</connection-url>
    <driver>oracle</driver>
    <pool>
        <min-pool-size>3</min-pool-size>
        <max-pool-size>20</max-pool-size>
        <prefill>true</prefill>
    </pool>
    <security>
        <user-name>...</user-name>
        <password>...</password>
    </security>
</datasource>
<drivers>
    <driver module="com.oracle.ojdbc4" name="oracle">
        <driver-class>oracle.jdbc.OracleDriver</driver-class>
    </driver>
</drivers>
</datasources>
...

Note that this method deploys the JDBC driver as a core module. There is an alternative to install as a deployment which can be found here. This link is one of the basis, even if not always complete for migration information.
The JNDI name will be: java:/XOracleDS.

1.3 Tomcat

In Tomcat the definition of the datasource is (can be) done in a context.xml file located in $CATALINA_HOME/conf/context.xml

<pre lang="xml">
<context>
...
<resource auth="Container" driverclassname="oracle.jdbc.driver.OracleDriver" maxactive="8" maxidle="4" name="jdbc/XOracleDS" password="..." type="javax.sql.DataSource" url="jdbc:oracle:thin:@localhost:1521:XE" username="..."></resource>
</context>

One thing to note is that the Tomcat JNDI name will be: java:/comp/env/jdbc/XOracleDS since the prefix is mandatory.