Monday, March 19, 2012

Installing new instance of JBoss 7.1.1 with Oracle 10+ database driver and datasource

Installing new instance of JBoss 7.1.1 with Oracle 10+ database driver and datasource
While installing a new instance of JBoss AS 5.1 GA consisted of unzipping the zip file into a directory and copying the jdbc driver into the server's lib directory, installing JBoss AS 7.1.1 requires more work. The following steps describes how to install a new instace of JBoss AS 7.1.1 (and 7.1.0), configure the Oracle JDBC driver and set a datasource.
  1. Download the JBoss AS 7.1.1 from http://www.jboss.org/jbossas/downloads/
  2. Unzip the archive file to a directory (e.g.: D:\bin\jboss-as-7.1.1.Final)
  3. set JBOSS_HOME environmental variable to the unzipped directory (e.g.: "D:\bin\jboss-as-7.1.1.Final")
  4. Run <JBOSS_HOME>/bin/add-user.bat to create an administrator user to be able to log in into the administration interface
  5. Configure Oracle driver & Datasource:
    1. Create directory: <JBOSS_HOME>\modules\oracle\jdbc\main
    2. Download ojdbc6.jar from Oracle (http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html). Note: ojdbc14.jar was not recognized by JBoss 7.1.0 Final.
    3. Copy ojdbc6.jar into the <JBOSS_HOME>\modules\oracle\jdbc\main
    4. Create the file module.xml with the following content:
    5. <?xml version="1.0" encoding="UTF-8"?>
      <module xmlns="urn:jboss:module:1.0" name="oracle.jdbc"><resources><resource-root path="ojdbc6.jar"/>
          </resources>
          <dependencies>
              <module name="javax.api"/>
              <module name="javax.transaction.api"/>
          </dependencies>
      </module>
      
    6. Edit the <datasource> entry in "\standalone\configuration\standalone.xml", by adding the followings. (Change the _datasource_name_, _jdbc_conncection_url_, _schema_name_, _password_ strings to match to your environment. The datasource name will be referenced by the your application, e.g.: in the persistence.xml)
    7. <subsystem xmlns="urn:jboss:domain:datasources:1.0">
          <datasources>
       ...
       <datasource 
              jndi-name="java:jboss/datasources/_datasource_name_" 
              pool-name="_datasource_name_" 
              enabled="true" 
              use-java-context="true">
                  <connection-url>_jdbc_connection_url_</connection-url>
                  <driver>oracle</driver>
                  <security>
                      <user-name>_schema_name_</user-name>
                      <password>_password_</password>
                  </security>
              </datasource>
              <drivers>
                  <driver name="oracle" module="oracle.jdbc"/>
                            ...
                        </drivers>
          </datasources>
      </subsystem>

No comments:

Post a Comment