small medium large xlarge

02 Apr 2016, 02:48
Shayne Koestler (1 post)

From the very beginning I have had trouble getting the h2 database to start. Running the first two commands in the book:

lein new luminus guestbook +h2 lein run

I noticed that this piece of output shown in the book was missing from my output.

[2016-02-29][INFO][guestbook.core] #’guestbook.db.core/db started

Then when calling the following function from the repl


results in

IllegalArgumentException db-spec mount.core.DerefableState@bd9ab27 is missing a required parameter (jdbc.clj:292

Any help would be much appreciated.

02 Apr 2016, 08:01
Christiaan Janssen (2 posts)

I have the exacte same isseu:

IllegalArgumentException db-spec mount.core.DerefableState@6ff92798 is missing a required parameter (jdbc.clj:292)

And no idea what is going on.

I would like to add that I have the feeling the database in sot running, if I isseu a (stop) from the repl I get:

[2016-04-02 09:59:39,317][DEBUG][org.projectodd.wunderboss.WunderBoss] Returning existing component for org.projectodd.wunderboss.web.Web:-1645144552, ignoring options.
[2016-04-02 09:59:39,331][INFO][luminus.http-server] HTTP server stopped
=> {:stopped ["#'guestbook.core/http-server"]}

And a (start) also only shows the http-server starting

02 Apr 2016, 08:42
Christiaan Janssen (2 posts)

I found a solution! It seems that the database is not loaded when we do a start and stop command.

you need to do this:

;;switch to the namespace
(require '[guestbook.db.core :refer :all])

;; Start the database

;;check if we have any existing data

That works for me

02 Apr 2016, 21:46
Dmitri Sotnikov (141 posts)

What’s happening here is that mount won’t initialize the database state unless it’s referenced somewhere. When you require the namespace then it becomes referenced and then it will be started.

You can also start it explicitly by running (mount.core/start #'guestbook.config/env #'guestbook.db.core/*db*). Note that the *db* state depends on the env state to get the database connection, so both would need to be started.

However, once you start using the database in another namespace then everything will work as expected automatically.

15 Apr 2016, 17:26
Daniel Lobato Garcia (1 post)

I had the same issue - which (start) fixed.

Page 12 of the beta book doesn’t make any mention of this, so if the future versions could have this in the book I think it’d be more ‘error-proof’

16 Apr 2016, 03:51
Dmitri Sotnikov (141 posts)

Good idea, I updated the wording to explain why the connection needs to be started manually.

21 Apr 2016, 00:03
yusef nathanson (1 post)

Just bought the book today. I’m suffering a different error with the database setup. When I run:

$ lein run migrate

I get this response:

[2016-04-20 19:38:12,958][DEBUG][org.jboss.logging] Logging Provider: org.jboss.logging.Log4jLoggerProvider
[2016-04-20 19:38:14,478][INFO][migratus.core] Starting migrations
[2016-04-20 19:38:14,843][INFO][migratus.database] creating migration table 'schema_migrations'
DEPRECATED: unrolled column specs / key/value arguments to create-table-ddl
[2016-04-20 19:38:14,850][INFO][migratus.core] Ending migrations
Exception in thread "main" java.lang.NullPointerException, compiling:(/private/var/folders/w5/0xydh_bj5sdgddlml7xwytyc0000gn/T/form-init228431613116001593.clj:1:124)
	at clojure.lang.Compiler.load(
	at clojure.lang.Compiler.loadFile(
	at clojure.main$load_script.invokeStatic(main.clj:275)
	at clojure.main$init_opt.invokeStatic(main.clj:277)
	at clojure.main$init_opt.invoke(main.clj:277)
	at clojure.main$initialize.invokeStatic(main.clj:308)
	at clojure.main$null_opt.invokeStatic(main.clj:342)
	at clojure.main$null_opt.invoke(main.clj:339)
	at clojure.main$main.invokeStatic(main.clj:421)
	at clojure.main$main.doInvoke(main.clj:384)
	at clojure.lang.RestFn.invoke(
	at clojure.lang.Var.invoke(
	at clojure.lang.AFn.applyToHelper(
	at clojure.lang.Var.applyTo(
	at clojure.main.main(
Caused by: java.lang.NullPointerException
	at clojure.core$name.invokeStatic(core.clj:1546)
	at clojure.core$name.invoke(core.clj:1540)
	at clojure.core$map$fn__4785.invoke(core.clj:2646)
	at clojure.lang.LazySeq.sval(
	at clojure.lang.LazySeq.seq(
	at clojure.core$next__4341.invokeStatic(core.clj:64)
	at clojure.string$join.invokeStatic(string.clj:180)
	at clojure.string$join.invoke(string.clj:180)
	at clojure.lang.RestFn.invoke(
	at migratus.database$init_schema_BANG_$fn__14842.invoke(database.clj:227)
	at migratus.database$init_schema_BANG_.invokeStatic(database.clj:220)
	at migratus.database$init_schema_BANG_.invoke(database.clj:219)
	at migratus.database.Database.connect(database.clj:262)
	at migratus.core$run.invokeStatic(core.clj:24)
	at migratus.core$run.invoke(core.clj:21)
	at migratus.core$migrate.invokeStatic(core.clj:63)
	at migratus.core$migrate.invoke(core.clj:60)
	at luminus_migrations.core$migrate.invokeStatic(core.clj:16)
	at luminus_migrations.core$migrate.invoke(core.clj:9)
	at guestbook.core$_main.invokeStatic(core.clj:57)
	at guestbook.core$_main.doInvoke(core.clj:52)
	at clojure.lang.RestFn.invoke(
	at clojure.lang.Var.invoke(
	at user$eval15354.invokeStatic(form-init228431613116001593.clj:1)
	at user$eval15354.invoke(form-init228431613116001593.clj:1)
	at clojure.lang.Compiler.eval(
	at clojure.lang.Compiler.eval(
	at clojure.lang.Compiler.load(
	... 14 more

I’ve been messing with it for hours but I just get the same error.

It seems that JDBC has broken compatibility with migratus. Check their github here.

I’m quite new to programming and this is a little over my head.

Help will be greatly appreciated!

21 Apr 2016, 04:00
Dmitri Sotnikov (141 posts)

You’re absolutely right. The latest API is incompatible. The fix is to rollback the conman library to version 0.4.9. I’ve updated the template accordingly as well. Sorry for the inconvenience.

27 Apr 2016, 12:19
Aditya Gore (1 post)

I had the same trouble starting the database as reported by others: “IllegalArgumentException db-spec mount.core.DerefableState@58922dd5 is missing…” etc. and (start) fixed it. Just leaving this comment here for completeness.

20 May 2016, 16:55
Patrick Huffer (8 posts)

I tried the following as described above but got an error:

(require '[guestbook.db.core :refer :all])
;; java.lang.RuntimeException: Unable to resolve symbol: get-messages in this context

Instead I have to add the namespace in order to get the generated functions to work.

;; => ()

Not sure what is going wrong?

21 May 2016, 04:14
Dmitri Sotnikov (141 posts)

Hmm, you should be able to call the functions from the namespace once you require it. The steps should be as follows.

run the app in a terminal with:

lein run

run the REPL in a separate terminal from the app directory

lein repl :connect 7000

In the REPL, you should be able to require the namespace, run (start), and call the functions:

(require '[guestbook.db.core :refer :all])
31 May 2016, 04:07
Paul Gowder (4 posts)

Can I suggest adding a note along those lines to the non-relational databases appendix too? I just ended up here after rooting around trying to figure out how to get mongodb running from the template.

Actually, that’s something that could be in the startup “you need to connect your database” messages that show up on the default home page for the template too. Right now, it just says “start the database and give it a reference in the env,” not “and also reference the namespace somewhere before restarting or it won’t start.” (Would you entertain a PR along those lines?)

31 May 2016, 12:25
Dmitri Sotnikov (141 posts)

I agree, a note regarding that would probably be helpful. If you’re up for making a PR for improved docs I’d be glad to integrate it.

31 May 2016, 16:31
Paul Gowder (4 posts)

Totally, will do. :-)

30 Apr 2017, 02:22
Geoffrey Clements (22 posts)

Fighting with this too. Bought the book today and started working through it. Created the guestbook project using the version of luminus specified in the book. Got the guestbook table missing error. (Migrations finished but didn’t actually run.) Fussed with it. Got frustrated. Deleted everything tried the latest version of luminus. Same issue. Finally looked up and found this thread. Tried reverting to corman 0.4.9 in the current version of luminus. Nope. Tried the version of luminus specified in the book with corman reverted back to 0.4.9. Migrations still don’t run and I get the exception:

Exception in thread "main" java.lang.ClassCastException: clojure.lang.PersistentVector (in module: Unnamed Module) cannot be cast to clojure.lang.Named (in module: Unnamed Module), compiling:(/tmp/form-init2580785282838157891.clj:1:73)


30 Apr 2017, 15:09
Dmitri Sotnikov (141 posts)

I just created a fresh project and I’m not able to reproduce the issue here:

lein new luminus guestbook +h2
cd guestbook

add migration files under resources/migrations/:

  • 20150719215253-guestbook.i[.sql:
-- START:guestbook-table
CREATE TABLE guestbook
 name VARCHAR(30),
 message VARCHAR(200),
 timestamp TIMESTAMP);
-- END:guestbook-table
  • 20150719215253-guestbook.down.sql
DROP TABLE guestbook;

Next, I run:

lein run migrate
2017-04-30 11:02:57,380 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
read config from resource: "config.edn"
read config from file: ".lein-env"
2017-04-30 11:02:59,235 [main] INFO  migratus.core - Starting migrations
2017-04-30 11:02:59,506 [main] INFO  migratus.database - creating migration table 'schema_migrations'
2017-04-30 11:02:59,552 [main] INFO  migratus.core - Running up for [20150719215253]
2017-04-30 11:02:59,553 [main] INFO  migratus.core - Up 20150719215253-guestbook
2017-04-30 11:02:59,570 [main] DEBUG migratus.database - found 1 up migrations
2017-04-30 11:02:59,590 [main] DEBUG migratus.database - marking 20150719215253 complete
2017-04-30 11:02:59,594 [main] INFO  migratus.core - Ending migrations

Note that the log indicates the migration it ran. Now I can run the REPL and confirm that the table exists and I can query it:

lein repl
2017-04-30 11:08:35,642 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
nREPL server started on port 50863 on host - nrepl://
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
OpenJDK 64-Bit Server VM 1.8.0_112-b16
    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 'guestbook.db.core)
user=> (start)
read config from resource: "config.edn"
read config from file: ".lein-env"
2017-04-30 11:08:48,749 [nREPL-worker-0] INFO  guestbook.env -
-=[guestbook started successfully using the development profile]=-
2017-04-30 11:08:48,852 [nREPL-worker-0] INFO  luminus.http-server - starting HTTP server on port 3000
2017-04-30 11:08:48,888 [nREPL-worker-0] INFO  org.xnio - XNIO version 3.3.6.Final
2017-04-30 11:08:49,009 [nREPL-worker-0] INFO  org.projectodd.wunderboss.web.Web - Registered web context /
{:started ["#'guestbook.config/env"
user=> (get-messages {})
user=> (save-message! {:name "Bob" :message "Hello" :timestamp (java.util.Date.)})
user=> (get-messages {})
({:id 1
  :message "Hello"
  :name "Bob"
  :timestamp #inst "2017-04-30T15:09:11.555-00:00"})
03 May 2017, 22:46
Roy Freeman (2 posts)

Hi, just bought the book and all was going well till I tried to start the database. on doing this in repl connected to port 7000

(require ‘[guestbook.db.core :refer :all])

i get this error

CompilerException clojure.lang.ExceptionInfo: Missing HugSQL Header of :name, :name-, :snip, or :snip- Found headers include: [:get-messages :doc] SQL: [“SELECT * from guestbook”] {}, compiling:(guestbook/db/core.clj:16:1)

any clues

03 May 2017, 22:53
Dmitri Sotnikov (141 posts)

Unfortunately, I haven’t seen this error before and I’m not able to reproduce it locally. A couple of things to check would be the version of the JDK and Leiningen that you have.

04 May 2017, 09:36
Roy Freeman (2 posts)

lein - version reports

Leiningen 2.7.1 on Java 1.8.0_102 Java HotSpot(TM) 64-Bit Server VM

I deleted the project and started again. The only change I made was to follow the online tutorial which edits the migrations files rather than as stated in the book to delete them and create new ones using migratus?

04 May 2017, 21:43
Dmitri Sotnikov (141 posts)

That all looks fine, and there shouldn’t be any problem deleting the migration files and making new ones. If you can post the project on GitHub, I could take a look and see if I can replicate the issue locally.

10 May 2017, 03:06
Geoffrey Clements (22 posts)


I finally had a chance to retry starting guestbook again on a different machine running MacOS instead of Ubuntu and this time the migrations ran fine and queries work. My guess is something is broken in the setup of my Ubuntu machine. Feel free to delete/ignore my comment above since this is working for me now. :)


10 May 2017, 03:35
Dmitri Sotnikov (141 posts)

Glad to hear it’s working. I wonder what was causing the problem on the Linux machine. The JVM is typically fairly platform independent. If you do get a chance to figure it out let me know.

01 Sep 2017, 04:28
Curtis Wallen (2 posts)

I’m having a similar problem to those above and it seems some people on GitHub have had the same problem.

[2016-02-29][INFO][guestbook.core] #'guestbook.db.core/*db* started is absent when I first execute lein run

And when I execute lein run migrate it appears to create the db but not the table:

guestbook curtis$ lein run migrate
[2017-08-31 21:18:48,062][DEBUG][org.jboss.logging] Logging Provider: org.jboss.logging.Log4jLoggerProvider
[2017-08-31 21:18:48,942][INFO][migratus.core] Starting migrations
[2017-08-31 21:18:49,186][INFO][migratus.database] creating migration table 'schema_migrations'
[2017-08-31 21:18:49,350][INFO][migratus.core] Ending migrations

I’ve tried everything suggested in this thread and on Github, but with no success. Any thoughts? I’m running macOS 10.12.6 and have set the plugin reference in .lein/profiles.clj to luminus/lein-template ""

EDIT: I uninstalled/reinstalled Leiningen and it seems to be working now. I also ran lein run migrate before lein run on the attempt when it worked. Not sure if that matters.

01 Sep 2017, 13:39
Dmitri Sotnikov (141 posts)

You definitely need to run lein run migrate first to create the database. The only other thing to be aware of is that the guestbook.db.core namespace need to be referred somewhere for it to be started automatically.

The mount library that manages the state of the database follows the namespace hierarchy to infer what resources need to be started. It starts from the guestbook.core namespace, and follows the hierarchy from there.

03 Sep 2017, 19:49
Curtis Wallen (2 posts)

Weird I think cider was somehow conflicting with the migration process?

Started running into the problem again:

norun curtis$ lein run migrate
[2017-09-03 15:42:53,476][DEBUG][org.jboss.logging] Logging Provider: org.jboss.logging.Log4jLoggerProvider
[2017-09-03 15:42:54,392][INFO][migratus.core] Starting migrations
[2017-09-03 15:42:54,642][INFO][migratus.database] creating migration table 'schema_migrations'
[2017-09-03 15:42:54,799][INFO][migratus.core] Ending migrations

Notice it never actually ran the up to create the table.

When I tried to run that migration my ~/.lein/profiles.clj included [cider/cider-nrepl "0.8.1"]

I took the cider plugin out and tried to run the migration again and it worked properly:

norun curtis$ lein run migrate
[2017-09-03 15:46:33,366][DEBUG][org.jboss.logging] Logging Provider: org.jboss.logging.Log4jLoggerProvider
[2017-09-03 15:46:34,304][INFO][migratus.core] Starting migrations
[2017-09-03 15:46:34,577][INFO][migratus.core] Running up for [20170903154358]
[2017-09-03 15:46:34,577][INFO][migratus.core] Up 20170903154358-newdb
[2017-09-03 15:46:34,582][DEBUG][migratus.database] found 1 up migrations
[2017-09-03 15:46:34,602][DEBUG][migratus.database] marking 20170903154358 complete
[2017-09-03 15:46:34,610][INFO][migratus.core] Ending migrations

A bit annoying, but good to know for anyone else potentially running into this problem.

03 Jan 2018, 15:42
Peter Wen (3 posts)

Looks like I am having a similar issue where >lein run migrate is not creating the database or table. I get this error on localhost:3000

org.h2.jdbc.JdbcSQLException at / Table “GUESTBOOK” not found; SQL statement: SELECT * from guestbook [42102-192]

This is the output after running migrate. I installed leiningen via hombrew. Attempted a uninstall/reinstall, but no change in the outcome.

Peters-MacBook% lein run migrate
[2018-01-03 10:35:32,033][DEBUG][org.jboss.logging] Logging Provider: org.jboss.logging.Log4jLoggerProvider
[2018-01-03 10:35:33,018][INFO][migratus.core] Starting migrations
[2018-01-03 10:35:33,530][INFO][migratus.core] Ending migrations
03 Jan 2018, 19:26
Peter Wen (3 posts)

Thanks, Dimitri,

I added :dependencies [migratus “1.0.3”] to project.clj and reran >lein run migrate and the table was created properly. Working now.

You must be logged in to comment