Fork me on GitHub
#luminus
<
2016-03-11
>
ricardo14:03:28

So… what’s the convention when dealing with keys that have dashes on the name, but working with a db that does not support them (say, Postgres)?

ricardo14:03:04

Say, foreign-id. Using foreignid as the column name, or having a mixture of dashes and underscores on the names, seem equally ugly.

Nicolas Boskovic20:03:44

I'm having a db issue with a recent version of Luminus (I think), where trying to operate on a database is giving me this: 'IllegalArgumentException db-spec mount.core.DerefableState@6dc3d84b is missing a required parameter clojure.java.jdbc/get-connection (jdbc.clj:292)'

Nicolas Boskovic20:03:18

I'm afraid the REPL connection didn't do it

Nicolas Boskovic20:03:22

And it doesn't seem to be an issue with the syntax for calling up the query or the query itself

curtis.summers20:03:46

Probably a question best answered by @yogthos . I've seen a few folks run into this with luminus & mount, but I'm not sure all of the steps for troubleshooting.

yogthos20:03:27

@nnbosko: you have to make sure that the database component is started

yogthos20:03:52

if you do lein run then start-app function gets called and starts up all the components

yogthos20:03:26

if you’re starting the repl then you probably want to either run that or run (start) in the user namespace, the repl should default to it

yogthos20:03:50

my recommended approach is to use lein run to start the app, and then connect to the nrepl that it starts on port 7000

Nicolas Boskovic20:03:14

Yes, it's what I just tried

yogthos20:03:38

another question is whether the database namespace is referenced anywhere

yogthos20:03:47

if it’s not then mount won’t start it automatically

yogthos20:03:42

something like (mount/start #’app.db.core/db)

Nicolas Boskovic20:03:46

It's required by an auth service, I'm on its namespace calling up a db query through it

yogthos20:03:58

that should cause it to start

Nicolas Boskovic20:03:08

Basically I'm going through the gallery tutorial on the Web dev book

yogthos20:03:08

do you see anything to that effect in the console log?

Nicolas Boskovic20:03:32

[2016-03-11 17:21:16,140][INFO][com.zaxxer.hikari.HikariDataSource] HikariPool-0 - is starting.

Nicolas Boskovic20:03:40

[2016-03-11 17:21:16,563][INFO][wstore.core] #'wstore.db.core/db started

yogthos20:03:08

ok so it should be running then

yogthos20:03:02

and your db.core namespace looks something like this at the top?

yogthos20:03:04

so that all looks right

yogthos20:03:12

at what point do you get the error?

Nicolas Boskovic20:03:25

It happens when I'm calling up the register! function

yogthos20:03:55

and are you calling it from the repl?

yogthos20:03:17

or from the route by the client?

Nicolas Boskovic20:03:19

Yes, which is connected to the app's nREPL server

Nicolas Boskovic20:03:34

Calling it from the client raises the same error

yogthos20:03:47

hmm everything seems like it should be in order

Nicolas Boskovic20:03:06

Yeah, I haven't really deviated from the tutorial either

yogthos20:03:23

can you try running (require '[mount.tools.graph :as graph]) (graph/states-with-deps)

yogthos20:03:29

to see what mount thinks is started

Nicolas Boskovic20:03:37

Here's the full trace

yogthos20:03:06

right postgres likes to wrap its exceptions

yogthos20:03:27

so looks like the state is started fine

yogthos20:03:38

I guess another thing to look at is your connection string

yogthos20:03:58

the profiles.clj file in the project folder should have a :database-url in it

yogthos20:03:17

that should be a url that will connect to your local postgres

Nicolas Boskovic20:03:32

Yes, the URL is correct

Nicolas Boskovic20:03:14

I'm going to check a previous project I had to see if I can hook up to the db from there

yogthos20:03:12

yeah I’m a bit stumped on this one

Nicolas Boskovic20:03:29

Ran a clean and rebuilt just in case, still nothing

yogthos20:03:23

hmm could you put it up on github maybe?

Nicolas Boskovic20:03:57

Do you have a gitlab account?

yogthos20:03:17

I could make one simple_smile

yogthos20:03:34

and yeah I’m not seeing this with a fresh app locally either

yogthos20:03:50

for example I got [2016-03-11 15:37:05,596][DEBUG][org.jboss.logging] Logging Provider: org.jboss.logging.Log4jLoggerProvider [2016-03-11 15:37:07,244][INFO][luminus.http-server] starting HTTP server on port 3000 [2016-03-11 15:37:07,308][INFO][org.xnio] XNIO version 3.4.0.Beta1 [2016-03-11 15:37:07,425][INFO][org.xnio.nio] XNIO NIO Implementation Version 3.4.0.Beta1 [2016-03-11 15:37:07,529][INFO][org.projectodd.wunderboss.web.Web] Registered web context / [2016-03-11 15:37:07,532][INFO][luminus.repl-server] starting nREPL server on port 7000 [2016-03-11 15:37:07,567][INFO][myapp.core] #'myapp.config/env started [2016-03-11 15:37:07,567][INFO][myapp.core] #'myapp.core/http-server started [2016-03-11 15:37:07,567][INFO][myapp.core] #'myapp.core/repl-server started [2016-03-11 15:37:07,568][INFO][myapp.env] -=[myapp started successfully using the development profile]=-

yogthos20:03:10

lein repl :connect 7000 Connecting to nREPL at 127.0.0.1:7000 REPL-y 0.3.7, nREPL 0.2.12 Clojure 1.8.0 Java HotSpot(TM) 64-Bit Server VM 1.8.0_45-b14 Docs: (doc function-name-here) (find-doc "part-of-name-here") Source: (source function-name-here) Javadoc: (javadoc java-object-or-class-here) Exit: Control+D or (exit) or (quit) Results: Stored in vars *1, *2, *3, an exception in *e user=> (use 'myapp.db.core) nil user=> (get-user {:id ""}) nil

yogthos20:03:29

so it’s definitely something funky in that specific project

curtis.summers20:03:51

Does your postgresql log file provide any clues?

Nicolas Boskovic21:03:47

I missed a column name by one letter, it was in the psql logs, thanks @curtis.summers

Nicolas Boskovic21:03:52

And thank you for your time, @yogthos

yogthos21:03:12

ah it’s always something silly simple_smile

Nicolas Boskovic21:03:36

Yes, the stack traces could be a little better for jdbc

yogthos21:03:44

they are terrible

yogthos21:03:59

it’s sad that it goes to the postgres log, but not back to the client

curtis.summers21:03:49

simple_smile I usually tail -f my postgresql log in a terminal when I'm writing a bunch of queries because of past experiences hunting for this kind of error. Glad you figured it out.

Nicolas Boskovic21:03:24

Thanks to you guys. Better keep going with this then simple_smile

yogthos21:03:36

@curtis.summers: and good call on checking the postgres log simple_smile

yogthos21:03:15

I always forget it has more info than what you get back in the errors on the client