eXo Platform 3.5

## Chapter 90. How to use AS Managed DataSource under JBoss AS

This chapter will show you how to use AS Managed DataSource under JBoss AS.

### Important

Checked under Gatein 3.1.0-GA Final

### Important

only no-tx-datasource is supported in JCR 1.12

## Declaring the datasources in the AS

Under JBoss, just put a file XXX-ds.xml in the deploy server (example: \server\default\deploy). In this file, we will configure all datasources which eXo will need. (there should be 4 named: jdbcjcr_portal, jdbcjcr_portal-sample, jdbcidm_portal & jdbcidm_sample-portal).

Example:

    <?xml version="1.0" encoding="UTF-8"?>

    <datasources>

       <no-tx-datasource>

          <jndi-name>jdbcjcr_portal</jndi-name>

          <connection-url>jdbc:hsqldb:${jboss.server.data.dir}/data/jdbcjcr_portal</connection-url>

          <driver-class>org.hsqldb.jdbcDriver</driver-class>

          <user-name>sa</user-name>

          <password></password>

       </no-tx-datasource>

       <no-tx-datasource>

          <jndi-name>jdbcjcr_sample-portal</jndi-name>

          <connection-url>jdbc:hsqldb:${jboss.server.data.dir}/data/jdbcjcr_sample-portal</connection-url>

          <driver-class>org.hsqldb.jdbcDriver</driver-class>

          <user-name>sa</user-name>

          <password></password>

       </no-tx-datasource>

       <no-tx-datasource>

          <jndi-name>jdbcidm_portal</jndi-name>

          <connection-url>jdbc:hsqldb:${jboss.server.data.dir}/data/jdbcidm_portal</connection-url>

          <driver-class>org.hsqldb.jdbcDriver</driver-class>

          <user-name>sa</user-name>

          <password></password>

       </no-tx-datasource>

       <no-tx-datasource>

          <jndi-name>jdbcidm_sample-portal</jndi-name>

          <connection-url>jdbc:hsqldb:${jboss.server.data.dir}/data/jdbcidm_sample-portal</connection-url>

          <driver-class>org.hsqldb.jdbcDriver</driver-class>

          <user-name>sa</user-name>

          <password></password>

       </no-tx-datasource>

    </datasources>

Which properties can be set for datasource can be found here: Configuring JDBC DataSources - The non transactional DataSource configuration schema

## Do not let eXo bind datasources explicitly

Edit server/default/conf/gatein/configuration.properties and comment out next rows in JCR section:

    #gatein.jcr.datasource.driver=org.hsqldb.jdbcDriver
    #gatein.jcr.datasource.url=jdbc:hsqldb:file:${gatein.db.data.dir}/data/jdbcjcr_${name}
    #gatein.jcr.datasource.username=sa
    #gatein.jcr.datasource.password=

and in IDM section:

    #gatein.idm.datasource.driver=org.hsqldb.jdbcDriver
    #gatein.idm.datasource.url=jdbc:hsqldb:file:${gatein.db.data.dir}/data/jdbcidm_${name}
    #gatein.idm.datasource.username=sa
    #gatein.idm.datasource.password=

In jcr-configuration.xml and idm-configuration.xml comment out the plugin InitialContextInitializer.

    <!-- Commented because, Datasources are declared and bound by AS, not in eXo -->

    <!--

    <external-component-plugins>

        [...]

    </external-component-plugins>

    -->

Running eXo after these configurations goes well.

Copyright © 2009-2012. All rights reserved. eXo Platform SAS