Friday, February 1, 2013

Configuring a Carbon Datasource in Geronimo

In this post I will explain how create an embedded Derby database and configure a Carbon Datasource in Apache Geronimo. This configured datasource is useful if you are deploying Carbon bundles or running Carbon in web-app mode under restricted conditions in Geronimo. 

For this purpose I'm using the Geronimo J2EE distribution with Tomcat 7 integration for Linux platform downloaded from here

We can use the created database in Geronimo to configure the Carbon master datasource and use it to for UserManager and Registry in Carbon.


1. In Geronimo console go to "Datasources" and click the Using the Geronimo database pool wizard link, and complete the following steps:

Step 1: 

Select Name and Database, enter WSO2CarbonDB for the Name of Database Pool field. Select Derby embedded from the Database Type pull-down menu, and click Next




Step 2: 

Select Driver, JAR, Parameters, select org.apache.geronimo.configs/system-database/3.0.0/car from the Driver JAR pull-down menu. 


Configure the database with required configurations;


Sample configuration:


Database Name :  WSO2_CARBON_DB
Username : wso2carbon
Password : wso2carbon





Step 3: 

After creating the Database pool, run the derby.sql using the created WSO2CarbonDB pool as the datasource. The db scripts to create the Registry and User Manager Database can be found in any Carbon product at $CARBON_HOME/dbscripts directory.






Step 4: 

Now get the JNDI object name for the created database and use it to configure the WSO2_CARBON_DB datasource in $CARBON_HOME/repository/conf/datasources/master-datasource.xml

Also change the database url to point to the newly created Database location.

eg: 





            WSO2_CARBON_DB
            The datasource used for registry and user manager
            
                jca:/console.dbpool/WSO2CarbonDB/JCAConnectionManager/WSO2CarbonDB
            
             
                
   jdbc:derby:/home/test/geronimo-tomcat7-javaee6-web-3.0.0/var/derby/WSO2_CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000
                    wso2carbon
                    wso2carbon
      org.apache.derby.jdbc.EmbeddedDriver
                    50
                    60000
                    true
                    SELECT 1
                    30000
                
            





Now you can use this datasource in user-mgt.xml and registry.xml in $CARBON_HOME/repository/conf as below. This is how we configure Registry and User Manager to use a database referred by a Carbon datasource.

1. In user-mgt.xml


                admin
                
                     admin
                     admin
                
            everyone 
     jca:/console.dbpool/jdbc_WSO2CarbonDB/JCAConnectionManager/jdbc/WSO2CarbonDB
            org.wso2.carbon.user.core.config.multitenancy.SimpleRealmConfigBuilder


2. In registry.xml

 jca:/console.dbpool/jdbc_WSO2CarbonDB/JCAConnectionManager/jdbc/WSO2CarbonDB





No comments:

Post a Comment