question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keycloak 17 (Quarkus): no suitable driver found for jdbc:postgresql

See original GitHub issue

Describe the bug

We are running Keycloak in AWS ECS for some time now and are planning to upgrade to Keycloak 17 (Quarkus). But the container won’t start with this error message:

ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: No suitable driver found for jdbc:postgresql://ecs-keycloak.xxxxxxxxxx.eu-west-1.rds.amazonaws.com/keycloak

The environment vars for the ECS task are as follows:

        "environment" : [
            { "name" : "KEYCLOAK_ADMIN", "value" : "${keycloak_username}" },
            { "name" : "KEYCLOAK_ADMIN_PASSWORD", "value" : "${keycloak_password}" },
            { "name" : "KC_PROXY", "value" : "edge" },
            { "name" : "KC_DB", "value" : "postgres" },
            { "name" : "KC_DB_URL_HOST", "value" : "${database_hostname}" },
            { "name" : "KC_DB_URL_DATABASE", "value" : "keycloak" },
            { "name" : "KC_DB_USERNAME", "value" : "${keycloak_rds_username}" },
            { "name" : "KC_DB_PASSWORD", "value" : "${keycloak_rds_password}" },
            { "name" : "KC_METRICS_ENABLED", "value" : "true" },
            { "name" : "KC_FEATURES", "value" : "preview" },
            { "name" : "KC_HTTP_RELATIVE_PATH", "value" : "/auth" },
            { "name" : "KC_HOSTNAME_STRICT", "value" : "false" },
            { "name" : "KC_CACHE_CONFIG_FILE", "value" : "cache-ispn-jdbc-ping.xml" }
        ],

The cache-file being used is this one.

Am i missing something? I’ve started the container locally (with start-dev) to check if the postgresql driver is present, but it is present in the container:

bash-4.4$ ls -l /opt/keycloak/lib/lib/main/ | grep postgres
-rw-rw-r-- 1 keycloak root    12059 Feb 11 19:15 io.quarkus.quarkus-devservices-postgresql-2.7.0.Final.jar
-rw-rw-r-- 1 keycloak root    17074 Feb 11 19:15 io.quarkus.quarkus-jdbc-postgresql-2.7.0.Final.jar
-rw-rw-r-- 1 keycloak root     6220 Feb 11 19:15 io.quarkus.quarkus-jdbc-postgresql-deployment-2.7.0.Final.jar
-rw-rw-r-- 1 keycloak root  1015689 Feb 11 19:15 org.postgresql.postgresql-42.3.1.jar
-rw-rw-r-- 1 keycloak root     9725 Feb 11 19:15 org.testcontainers.postgresql-1.16.3.jar

So i’m lost as to what is causing this. Is it because it is an AWS RDS running PostgreSQL 11?

Version

17.0.0

Expected behavior

Working Postgresql driver (even with AWS RDS Postgresql)

Actual behavior

ERROR: No suitable driver found for jdbc:postgresql://ecs-keycloak.xxxxxxxxxx.eu-west-1.rds.amazonaws.com/keycloak

How to Reproduce?

Try running it in AWS ECS. This is our docker file:

FROM quay.io/keycloak/keycloak:17.0.0 as builder

ENV KC_CACHE_CONFIG_FILE=cache-ispn-jdbc-ping.xml

COPY ./cache-ispn-jdbc-ping.xml /opt/keycloak/conf/cache-ispn-jdbc-ping.xml

RUN /opt/keycloak/bin/kc.sh build

FROM quay.io/keycloak/keycloak:17.0.0

COPY --from=builder /opt/keycloak/lib/quarkus/ /opt/keycloak/lib/quarkus/

# Install Metrics plugin
COPY keycloak-metrics-spi-2.5.3.jar /opt/keycloak/providers/

# Install PrivacyIDEA plugin
COPY PrivacyIDEA-Provider.jar /opt/keycloak/providers/

# Install Themes
COPY themes/ /opt/keycloak/themes/

# Install SSO CA AD cert
COPY files/ca.crt /tmp/ca.crt

USER root

RUN keytool -import -trustcacerts -alias local-CA -file /tmp/ca.crt -keystore /usr/lib/jvm/jre/lib/security/cacerts -storepass changeit -noprompt

USER 1000

EXPOSE 7600

ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start"]

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Brezensalzercommented, Mar 3, 2022

Hi, you have to build your own docker image to make the postgres jdbc driver available. A minimal dockerfile should look like this:

FROM quay.io/keycloak/keycloak:17.0.0

USER 1000
WORKDIR /opt/keycloak
RUN ./bin/kc.sh build --cache=ispn --cache-stack=kubernetes --db=postgres

ENTRYPOINT [ "./bin/kc.sh" ]`

This worked for me.

0reactions
Fabian1976commented, Mar 3, 2022

Adding the ENV parameter for the DB type before the build fixed it for me also! Tnx for the help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keycloak 17.0.0 docker image can't find ... - Stack Overflow
So it should be build parameter --db=postgres . BTW: I would use quay.io/keycloak/keycloak:17.0.0 image (17.0.0 is first stable Quarkus based ...
Read more >
Keycloak X preview with PostgreSQL Database
Hello, I try to deploy the new Keycloak X preview version with a ... No suitable driver found for jdbc:postgresql://localhost:5432/keycloak.
Read more >
Keycloak-x database driver missing - Google Groups
I am testing out the 16.1.1 preview release of Keycloak-x. ... '<default>': No suitable driver found for jdbc:postgresql://localhost:5432/keycloak
Read more >
Keycloak 17.0.0 docker image can't find suitable driver for ...
So it should be build parameter --db=postgres . BTW: I would use quay.io/keycloak/keycloak:17.0.0 image (17.0.0 is first stable Quarkus based Keycloak ...
Read more >
Keycloak and postgres integration issue in kubernetes
Hi, When installing keycloak with postgres getting below error. ... (main) ERROR: No suitable driver found for jdbc:postgresql://kc.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found