CUBA UberJar + Heroku: Can we use ${JDBC_DATABASE_URL}?

I am trying to use CUBA with Heroku.
Heroku specifies that you should use the environment var DATABASE_URL to connect to their PostgreSQL database. They describe that you should not copy paste the credentials because they could change, but this is what the CUBA documentation tells me to do.

The DATABASE_URL is in an invalid URI format, so they provided the environment variable JDBC_DATABASE_URL.

I configured UberJar to use this environment variable like so:

task buildUberJar(type: CubaUberJarBuilding) {
logbackConfigurationFile = 'etc/uber-jar-logback.xml'
singleJar = true
appProperties = ['cuba.automaticDatabaseUpdate': true,
                 'cuba.dataSource.jdbcUrl'     : '${JDBC_DATABASE_URL}',
                 'cuba.dataSourceProvider'     : 'application']


Then I build and deploy with (I added the heroku-gradle plugin):

./gradlew buildUberJar deployHeroku

The application starts, but gives the error:

Caused by: java.lang.RuntimeException: Driver org.hsqldb.jdbc.JDBCDriver claims to not accept jdbcUrl, jdbc:postgresql://

As you can see it is trying to use the hsqldb driver, instead of the postgresql driver.

How can I add the postgresql driver? (I am used to maven)
Is it possible to configure CUBA using JDBC_DATABASE_URL?

Hi @martijn.raats,

Recently, @mario posted a “how to” about it: Deploy CUBA to Heroku in ten steps.

Take a look and see if it helps.


Thank you.

For some reason my UberJar can still not find (after adding the spring profile) the postgres driver:

Caused by: java.lang.RuntimeException: Failed to load driver class org.postgresql.Driver in either of HikariConfig class loader or Thread context classloader

Edit: I noticed this happened after I chose my ‘local’ datasource to be HSQL. I added the dependency manually:

configure(coreModule) {

configurations {

dependencies {
    compile group: '', name: 'spring-security-config', version: '5.3.3.RELEASE'
    compile group: '', name: 'spring-security-web', version: '5.3.3.RELEASE'

Not sure if this is what I am supposed to do though.


First - if you plan to use PostgreSQL at deployment time, it is a good idea to permanently switch your project to use PostgreSQL in Main data store settings.
Because databases do differ in their behavior, and you risk catching some problems only at deployment time if you don’t code and test your application with Postgres.

HSQL is good only for fast prototyping, it’s not for serious development.

To make your project be able to work with Postgres without permanently switching main DBMS from HSQL, you need to:

  • add JDBC driver dependency to build.gradle
  • run CUBA -> Generate Database scripts to generate database init scripts for postgres. Otherwise database schema will not be able to initialize.
  • set “cuba.dbmsType” at some point, e.g. in UberJar building task arguments.

Thank you for the insight.

We intend to work with a team on the same project. I would like to have the minimum set of instructions for the developers, so having the HSQL local database was perfect. To instruct them to start Postgres (on docker or something) is a little more cumbersome. Or is there some sort of support within Cuba (studio)? Sharing a network database would also be possible but not ideal I would say for local development.


Not planned at the moment.

I don’t see any problem for every developer to install local PostgreSQL. It has installers for all operating systems, it’s free to use, it’s not hard to install.
And there are Docker images available, if you like to Docker-ize everything.