Fork me on GitHub

i started a new luminus template project and added one sql function and set up my db urls so that everything's working with the db connection itself but i'm getting a CompilerException java.lang.IllegalArgumentException: db-spec [email protected] is missing a required parameter, compiling:(checker.clj:26:34) when i try to compile or run a repl when i try to access that db function from a second namespace. if i run mount.core/start in that second namespace, it works for the repl and with lein run but lein uberjar fails and it seems like that is unnecessary as mount.core/start is called from the function that starts the app. if i remove the call to the db function in that second namespace, it works fine. i also tried requiring this second namespace in the core namespace that starts the app but that didn't seem to have any effect. any ideas?


@lucian303 can you share some code? you only need a single (mount/start) for everything to work. In case of an uberjar, usually, a (mount/start) is called from within a -main method in "xyz" namespace. In order for it to work, that "xyz" namespace should (:require [...]) namespaces with states. It does not need to require all of them, as it would find them transitively: i.e. if you require just a namespace a that in turn requires a namespace b, a is all you need.


@tolitius i set up a repo here to demonstrate the problem: ... the only changes i made from lein new luminus testing +swagger +service +mysql are to add the db urls to profiles.clj, my own db function to the sql file and a call to that function in the namespace to show the problem. i can only start the repl / server if the call to mount in is there, but that doesn't help the uberjar which throws an exception cause the db is not started. also, as u say, that should be unnecessary since start is called in the testing.core ns ...


> and a call to that function in the namespace


the problem is this is a "global" call to the database on the application start


i.e. the app should have a chance to start first


and then you can call a function with a resource


this line: calls into a db before the app ( with all its resources ) is started


i.e. it is top level, but it should be inside a function


I also noticed you did not setup db properties:

(!) read config from file: ".lein-env", but it is empty

Exception one of :jdbc-url, :adapter, :datasource, or :datasource-classname is required to initialize the connection!  conman.core/make-config (core.clj:56)


you can ask about these on the #luminus channel


as to mount, you can certainly call (db/get-term-names) in REPL or within a function after the initial call to (mount/start)


@tolitius i updated the code slightly to make the call inside a function (which is how my real code is) but the problem is the same. the repl will not start when i reference anything from the db because the db isn't started by mount


the db works and i am getting data out of it so there's no need to worry about those calls


@tolitius i figured out my problem was that the call to the db function should be wrapped in a defstate also so it's not global since it depends on the db (and therefore is a service with state). thanks for your help