# Using Crate JDBC in Dockerfile for Keycloak

**URL:** https://community.cratedb.com/t/using-crate-jdbc-in-dockerfile-for-keycloak/1524
**Category:** Integrations
**Tags:** integration
**Created:** [June 26, 2023, 12:49pm UTC](https://community.cratedb.com/t/using-crate-jdbc-in-dockerfile-for-keycloak/1524 "2023-06-26T12:49:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dennisn00](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/dennisn00/32/948_2.png) [@dennisn00](https://community.cratedb.com/u/dennisn00)
#### Post date: [June 26, 2023, 12:49pm UTC](https://community.cratedb.com/t/using-crate-jdbc-in-dockerfile-for-keycloak/1524/1 "2023-06-26T12:49:24Z")

</div>

Hello everyone,  
I want to use CrateDB for my Keycloak server that is running as a Docker Container. Using the Postgres Driver that Keycloak offers, I get some problems with SQL statements that are not supported by Crate (ROLLBACK amongst others). So I figured I can try using the Crate JDBC standalone driver instead.  
In my dockerfile, I am downloading the jar and then adding the path to the Classpath. Then I am using the Crate URL and login which work for example in Spring Boot. My Dockerfile is attached below. However when running the container, I get the Exception

> java.lang.ClassNotFoundException: io.crate.client.jdbc.CrateDriver

I am not sure where there problem is here. I can see that the jar is correctly downloaded into the drivers folder. Is the drivers name ( `io.crate.client.jdbc.CrateDriver`) correct or do I need to provide a whole path? Or is there any problem that prohibits using Keycloak and Crate together at all?

Dockerfile:

```auto
> 
> FROM quay.io/keycloak/keycloak:latest as builder
> 
> # Configure a database vendor
> ENV KC_DB=postgres
> 
> WORKDIR /opt/keycloak
> 
> RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore
> RUN /opt/keycloak/bin/kc.sh build
> 
> FROM quay.io/keycloak/keycloak:latest
> COPY --from=builder /opt/keycloak/ /opt/keycloak/
> 
> ADD --chown=keycloak:keycloak https://repo1.maven.org/maven2/io/crate/crate-jdbc-standalone/2.7.0/crate-jdbc-standalone-2.7.0.jar /drivers/
> 
> ENV CLASSPATH=/drivers/crate-jdbc-standalone-2.7.0.jar
> 
> ENV KC_DB=postgres
> ENV KC_DB_URL=jdbc:postgresql://<ip_address>:5432/doc
> ENV KC_DB_USERNAME=user
> ENV KC_DB_PASSWORD=password
> ENV KC_DB_DRIVER=io.crate.client.jdbc.CrateDriver
> ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]

```

---

<div class="post-metadata">

### Author: ![hernanc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/hernanc/32/676_2.png) [@hernanc](https://community.cratedb.com/u/hernanc)
#### Post date: [June 27, 2023, 11:15am UTC](https://community.cratedb.com/t/using-crate-jdbc-in-dockerfile-for-keycloak/1524/2 "2023-06-27T11:15:15Z")

</div>

Hi,  
`io.crate.client.jdbc.CrateDriver` is the correct class name for the CrateDB JDBC driver.  
I do not have experience with Keycloak, but maybe instead of trying to set the class path you could find the directory where the other drivers are and place the jar there?

Another option is that I see Keycloak has some settings with intriguing names for which I could not find any documentation: `transaction-xa-enabled` / `KC_DB_TX_TYPE`  
Maybe disabling these it could work against CrateDB with the standard PostgreSQL driver?

---

<div class="post-metadata">

### Author: ![dennisn00](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/dennisn00/32/948_2.png) [@dennisn00](https://community.cratedb.com/u/dennisn00)
#### Post date: [June 28, 2023, 8:18am UTC](https://community.cratedb.com/t/using-crate-jdbc-in-dockerfile-for-keycloak/1524/4 "2023-06-28T08:18:07Z")

</div>

Thank you for your response!

> [@hernanc](#):
>
> I do not have experience with Keycloak, but maybe instead of trying to set the class path you could find the directory where the other drivers are and place the jar there?

I tried it with the directory in which I found the postgres Driver:

```auto
ADD --chown=keycloak:keycloak https://repo1.maven.org/maven2/io/crate/crate-jdbc-standalone/2.7.0/crate-jdbc-standalone-2.7.0.jar /opt/keycloak/lib/lib/main/
ENV CLASSPATH=/opt/keycloak/lib/lib/main/crate-jdbc-standalone-2.7.0.jar
...
ENV KC_DB_DRIVER=io.crate.client.jdbc.CrateDriver

```

I still get the same exception.

> [@hernanc](#):
>
> Another option is that I see Keycloak has some settings with intriguing names for which I could not find any documentation: `transaction-xa-enabled` / `KC_DB_TX_TYPE`  
> Maybe disabling these it could work against CrateDB with the standard PostgreSQL driver?

I tried running the docker container without specifiying a custom driver in the dockerfile and using this command:

```auto
docker run -p 8443:8443 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin -e KC_DB_TX_TYPE=disabled cratecloak --verbose start-dev --transaction-xa-enabled=false

```

but I still get the problem  
`PSQLException: ERROR: line 1:1: mismatched input 'ROLLBACK'`
