Geronimo Datasource installation using a Deployment Plan

Geronimo Datasource installation using a Deployment Plan
Geronimo provides several administration channels; one of them is the command line administration interface or CLI from now on.
The CLI allows you to manage, administrate, and monitor any applications or modules which application server exposes to the administrators. So we can perform several deployment tasks just by firing up a terminal, navigating to Geronimo bin directory and executing the deploy script which is either a shell script in UNIX based operating systems or a batch file in Windows operating system.
Installing datasource on several developper's machine can be a very annoying tasks you can automate using the deploy shell command. In the following example i will demonstrate how to create a Derby datasource and how to deploy using a simple shell script
The following tutorial is based on Geronimo version 3.0
1) Define your datasource details
Create an xml file named datasource-plan.xml.

<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">
<dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">
<dep:moduleId>
<dep:groupId>console.dbpool</dep:groupId>
<dep:artifactId>MyApplicationDS</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>car</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>org.apache.geronimo.configs</dep:groupId>
<dep:artifactId>system-database</dep:artifactId>
<dep:version>3.0-beta-1</dep:version>
<dep:type>car</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<resourceadapter>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
<connectiondefinition-instance>
<name>MyApplicationDS</name>
<config-property-setting name="DatabaseName">MyApplicationDB</config-property-setting>
<config-property-setting name="ShutdownDatabase"/>
<config-property-setting name="Password">mypassword</config-property-setting>
<config-property-setting name="UserName">myuser</config-property-setting>
<config-property-setting name="LoginTimeout"/>
<connectionmanager>
<local-transaction/>
<single-pool>
<max-size>10</max-size>
<min-size>0</min-size>
<match-one/>
</single-pool>
</connectionmanager>
</connectiondefinition-instance>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
</connector>
2) Create a script to deploy your datasource
In this chapter we will create a script to deploy the datasource using the deploy command available in the bin directory of Geronimo.
In a Linux/Unix or Mac OSX system your script will look like :
deploy_datasource.sh
GERONIMO_HOME=/Application/geronimo
CONNECTOR=$GERONIMO_HOME/repository/org/tranql/tranql-connector-derby-embed-local/1.7/tranql-connector-derby-embed-local-1.7.rar
sh $GERONIMO_HOME/bin/deploy deploy datasource-plan.xml $CONNECTOR
The first line define the location of your Geronimo installation
On line 2 the connector correponding to Derby Embedded
The last line execute the deploy command passing the datasource plan we just created and the reference to the correponding Derby connector
The same script for Windows :
deploy_datasource.bat
set GERONIMO_HOME=D:\programs\geronimo-3.0-beta-1-Jetty
set CONNECTOR=%GERONIMO_HOME%/repository/org/tranql/tranql-connector-derby-embed-local/1.7/tranql-connector-derby-embed-local-1.7.rar
%GERONIMO_HOME%/bin/deploy.bat deploy datasource-plan.xml %CONNECTOR%
3) Executing the script
To execute the script you need to provide the administration login and password of your Geronimo instance.

>deploy.bat deploy datasource-plan.xml D:\programs\geronimo-3.0-beta-1-Jetty/repository/org/tranql/tranql-connector-derby-embed-local/1.7/tranql-connector-derby-embed-local-1.7.rar
Using GERONIMO_HOME: D:\programs\geronimo-3.0-beta-1-Jetty
Using GERONIMO_TMPDIR: var\temp
Using JRE_HOME: C:\programs\jdk1.6.0_23\jre
Username: system
Password: *******
Deployed console.dbpool/MYApplicationDS/1.0/car
If you received the message provided in line 7 your datasource has been deployed in your Geronimo application server.
Tags:
deploy,
deployment,
shell,
create,
geronimo,
datasource,
script,
based,
tasks

Sébastien Dante Ursini
Java/Finance Specialist
17 Years of experience in Java
22 Year in Banking/Finance
Based in Geneva/Switzerland
Recent Articles by Sébastien Dante Ursini :
Add comment