Fork me on GitHub
#duct
<
2018-03-12
>
myguidingstar11:03:39

@weavejester I got this error when trying to use mysql ClassNotFoundException com.mysql.cj.core.log.duct.logger.timbre.TimbreLogger@59869ae java.net.URLClassLoader.findClass (URLClassLoader.java:381)

myguidingstar11:03:25

I started with the lein template with +sqlite, then added [mysql/mysql-connector-java "5.1.45"]

myguidingstar11:03:52

then :duct.module/sql {:database-url "jdbc:}

myguidingstar11:03:26

am I missing something?

myguidingstar11:03:32

I tried [mysql/mysql-connector-java "8.0.8-dmr"], too, but still the same error

weavejester11:03:38

@myguidingstar What does the module produce? If you (prep) and then run (:duct.database.sql/hikaricp config), what do you get?

myguidingstar11:03:58

wait a minute 🙂

myguidingstar11:03:31

{:jdbc-url "jdbc:", :logger #integrant.core.Ref{:key :duct/logger}}

myguidingstar11:03:20

I still have :duct.module/logging {} in my config.edn

weavejester11:03:21

That seems fine… What’s the stacktrace for the error you received?

weavejester11:03:31

What version of the duct/database.sql.hikaricp library are you using?

myguidingstar11:03:31

:dependencies [[org.clojure/clojure "1.9.0"]
                 [duct/core "0.6.2"]
                 [duct/module.logging "0.3.1"]
                 [duct/module.web "0.6.4"]
                 [duct/module.ataraxy "0.2.0"]
                 [duct/module.sql "0.4.2"]
                 ;;[mysql/mysql-connector-java "5.1.45"]
                 [mysql/mysql-connector-java "8.0.8-dmr"]
                 ;;[org.xerial/sqlite-jdbc "3.21.0.1"]
                 ]

weavejester11:03:02

Try redefining the init-key method for hikaricp at the REPL, and see if that solves the problem:

(defmethod ig/init-key :duct.database.sql/hikaricp [_ {:keys [logger] :as options}]
  (sql/->Boundary {:datasource (-> (hikari-cp/make-datasource (dissoc options :logger))
                                   (cond-> logger (wrap-logger logger)))}))

weavejester11:03:13

It might be that the HikariCP wrapper is passing along the :logger key to the MySQL JDBC adapter somehow.

myguidingstar11:03:53

what is sql ns alias?

weavejester11:03:19

Oh, it’s duct.database.sql

myguidingstar11:03:27

and hikari-cp?

weavejester11:03:57

(:require [integrant.core :as ig]
            [duct.database.sql :as sql]
            [duct.logger :as log]
            [hikari-cp.core :as hikari-cp])

myguidingstar11:03:38

unbalanced parens somewhere...

weavejester11:03:15

Oh, at the end of (dissoc options :logger). Let me edit the message to fix it.

myguidingstar11:03:25

wrap-logger not found

weavejester11:03:44

Change it to: #'duct.database.sql.hikaricp/wrap-logger

myguidingstar12:03:09

okay, I can (q "SELECT 2") now

myguidingstar12:03:17

so what's the problem?

weavejester12:03:46

The :logger key is being added as a datasource property

weavejester12:03:16

The solution is to add that extra dissoc to the duct/database.sql.hikaricp library

myguidingstar12:03:50

so is it a conflict of using the same keyword?

weavejester12:03:10

Well, it’s that MySQL has a datasource property called “logger”, while the other databases I’ve tested on don’t. I didn’t realise that the hikari-cp wrapper would pass the extra option through.

weavejester12:03:35

I’ll fix it in a little while.

myguidingstar12:03:44

great, thank you so much

myguidingstar12:03:01

Duct is the best dev experience I've had

myguidingstar12:03:11

btw, I'm about to release a library to query sql using datomic pull syntax called walkable https://github.com/walkable-server/walkable

myguidingstar12:03:02

Duct plays an important role in my dev process

myguidingstar12:03:22

thank you so much 🙂