Keycloak-x database driver missing

3,270 views
Skip to first unread message

Garth

unread,
Feb 10, 2022, 3:55:20 PM2/10/22
to keyclo...@googlegroups.com
Hi All,

I am testing out the 16.1.1 preview release of Keycloak-x. When I try to specify the `--db-url` option when using `start-dev`, I get an error that it could not find the driver.

I see the postgres driver jar in `lib/lib/main/org.postgresql.postgresql-42.3.1.jar`.

Am I specifying the option incorrectly? Is there something else I must do in order to start it properly?

Thanks!

```
[garth:keycloak.x-16.1.1]$ ./bin/kc.sh start-dev --db-url=jdbc:postgresql://localhost:5432/keycloak
2022-02-10 21:49:55,422 INFO [org.key.qua.run.hos.DefaultHostnameProvider] (main) Hostname settings: FrontEnd: <request>, Strict HTTPS: false, Path: <request>, Strict BackChannel: false, Admin: <request>
2022-02-10 21:49:55,650 WARN [io.agr.pool] (agroal-11) Datasource '<default>': No suitable driver found for jdbc:postgresql://localhost:5432/keycloak
2022-02-10 21:49:55,651 WARN [org.hib.eng.jdb.env.int.JdbcEnvironmentInitiator] (JPA Startup Thread: keycloak-default) HHH000342: Could not obtain connection to query metadata: java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/keycloak
at org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:191)
at org.h2.jdbcx.JdbcDataSource.getXAConnection(JdbcDataSource.java:352)
at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:210)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:509)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:490)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
```

Niko Köbler

unread,
Feb 11, 2022, 2:53:08 AM2/11/22
to Keycloak User
You also have to set the "db" argument.
Keycloak does not deviate the driver just from the db-url, you have to set it explicitly.

Garth

unread,
Feb 11, 2022, 8:40:02 AM2/11/22
to Niko Köbler, keyclo...@googlegroups.com
Thanks Niko. It works!

I missed this because the `--db` param is not specified in the `start` help, only the `start-dev` help. This should be added to the help for `start`. Also, I noted that the other db params indicate that "If the `db-url` option is set, this option is ignored". I don't see why it shouldn't be the same for the database vendor as well, as it is common in other applications to only specify the JDBC url and then have the driver inferred (with ability to override).
> --
> You received this message because you are subscribed to the Google
> Groups "Keycloak User" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to keycloak-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/keycloak-user/04a30a26-d692-482e-bc4e-2010d5d98eacn%40googlegroups.com
> <https://groups.google.com/d/msgid/keycloak-user/04a30a26-d692-482e-bc4e-2010d5d98eacn%40googlegroups.com?utm_medium=email&utm_source=footer>.

Dominik Guhr

unread,
Feb 11, 2022, 9:14:48 AM2/11/22
to Garth, Niko Köbler, Keycloak User
Hey Garth and Niko,

thanks for raising this. 

For the "DB is not shown for start" part: It is not shown because you can't use it with the "start" command, but usually only for the "build" or "start-dev" command, as it is a build option. So this is wanted, nevertheless the docs are not quite official, so for sure this may cause some confusion. You can find the docs in [1] - to build them into an asciidoc page you could run mvn clean install from the docs subdirectory and then find an index.html in target/generated-docs - or you wait, with the release of keycloak 17 there'll also be a guides release including all of them. I think the most relevant are the configuration guide and the db guide.

For "inferring the needed driver from the url": Feel free to open a discussion around this under [2] - sounds like a good enhancement for one of the next versions for me at first glance :)


Garth

unread,
Feb 11, 2022, 12:12:29 PM2/11/22
to keyclo...@googlegroups.com
Thanks Dominik.

Regarding your comment about "you can't use it with the "start" command", then how would you specify the database when you are using the "auto-build" flag?

In any case, thanks for the pointers to the docs. I'll start a discussion on the db vendor inference from the JDBC url.
>> > an email to keycloak-use...@googlegroups.com <mailto:keycloak-user%2Bunsu...@googlegroups.com>.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msgid/keycloak-user/04a30a26-d692-482e-bc4e-2010d5d98eacn%40googlegroups.com
>> > <https://groups.google.com/d/msgid/keycloak-user/04a30a26-d692-482e-bc4e-2010d5d98eacn%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Keycloak User" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to keycloak-use...@googlegroups.com <mailto:keycloak-user%2Bunsu...@googlegroups.com>.
> --
> You received this message because you are subscribed to the Google
> Groups "Keycloak User" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to keycloak-use...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/keycloak-user/CAChHV7BTyYfSWGw4fwAaxHQ1%2BZp2Jd0VAd4ipk%3D0wGbTQe8YkQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/keycloak-user/CAChHV7BTyYfSWGw4fwAaxHQ1%2BZp2Jd0VAd4ipk%3D0wGbTQe8YkQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Dominik Guhr

unread,
Feb 12, 2022, 3:16:52 AM2/12/22
to Garth, Keycloak User
Hey Garth,

Sure, using the auto-build flag is different, there you can set the database. And you also get all options when you do kc.sh start --auto-build -h :-) 

Reply all
Reply to author
Forward
0 new messages