Last updated Jun 13, 2024

Declaring JNDI datasources in AMPS

This page describes how to declare a datasource in AMPS.


JNDI Datasources are useful when:

  • A plugin needs to access another database than the default one,
  • You want the product to store its data in the database you specify: Postgres, MySQL, ...

The datasource support was introduced by AMPS-737.


 Use the datasource through a pluginUse the datasource for the product's data
JIRA using AMPSYesNo
All other productsYesN/A

You can go through the setup of Confluence and tell it to use the datasource you've just provided, such as jdbc/DefaultDS. For JIRA, it is a little more complicated: You need to declare the file dbconfig.xml.


You can checkout this example on BitBucket: Examples using JNDI datasources for JIRA and Confluence.

Declare the datasource in the pom.xml

In the following example, we declare the JNDI datasource jdbc/DefaultDS and make it target a local Postgres instance. 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""
    <name>Datasource Example</name>
                <!-- Run me with "mvn clean amps:run" -->

Notice how we set the Data Path to an empty directory: If you start Confluence using an empty Home, the setup process will be displayed. During the setup process, you will have the opportunity to tell Confluence to store its data in the JNDI datasource java:comp/env/jdbc/DefaultDS.

Start your product

Using the previous pom.xml, you can start the product using:



This feature relies on CodeHaus Cargo to launch Tomcat with the datasource. You can get more understanding of the properties by reading Cargo Configuration for Tomcat 6.x .

ParameterDefault ValueDescription
jndi-The JNDI string for application to lookup
driver-The class of the JDBC driver, such as "org.hsqldb.jdbcDriver"
url-The JDBC url, such as jdbc:hsqldb:/path/to/database
username-The username to connect to the database
password-The password to connect to the database
typeWill not be sent to Cargo if emptyThe type of driver, such as "java.sql.Driver" or "javax.sql.XADataSource"
transactionSupportWill not be sent to Cargo if emptyLOCAL_TRANSACTION or XA_TRANSACTION
propertiesWill not be sent to Cargo if emptyProperties to pass to the driver. Semi-colon delimited string.
cargoStringWill be built using the other values if emptyInstead of providing any other value, you can directly pass the string for Cargo

Known Issues

There is no user interface to tell JIRA to use the provided datasource to store its data. However, it is still possible to use AMPS to declare the datasource; You will just need to provide JIRA with the dbconfig.xml. Please open the BitBucket repository for an example: Examples using JNDI datasources for JIRA and Confluence

Rate this page: