Closed bitfl1pper closed 10 years ago
I'm actually in the process of changing the example for that. The io/resource-path
is not a good default as you already noticed. :) I'll release a new template shortly.
Out of general curiosity, do you know why it would give the runtime exception after jar creation, when it would run fine from the lein ring server during development? Like some sort of underlying technical reason?
The problem is that the filesystem inside the jar is read only, so when you compile the resources folder into the jar the db can no longer be written to. The other problem was that the location for the db file was in the public folder, which is definitely not a good idea for an actual app.
I updated the docs here, they should get reflected in the site shortly, it polls github every half hour.
Cool! I'm looking forward to learning this framework deeply. Hopefully will contribute someday.
I just pushed out a new template as well, now the database file will be created at the path where the app is run. You'd probably want to specify the path explicitly for deployments, e.g.: /var/app/db
. In general though, I'd recommend going with something like Postgres for real apps.
And hopefully there's not too much to learn with regards to the framework. I tried to keep the scaffolding to a minimum and avoid doing any magic in the templates. My experience building Clojure apps has been that the best approach is to pick the libraries that fit the app and wire them together explicitly in a way that fits with your project.
This is quite different from frameworks such as Rails, where a lot of things are done by convention and the framework often dictates the way you structure the application.
I was able to successfully create a standalone jar to deploy my practice application to one of my test servers. When I called the equivalent of:
java -jar /var/myapp/myapp.jar
on my server I got a runtime exception
Exception in thread "main" org.h2.jdbc.JdbcSQLException: A file path that is implicitly relative to the current working directory is not allowed in the database URL "jdbc:h2:site.db". Use an absolute path, ~/name, ./name, or the baseDir setting instead.
I looked at the source of the guestbook.db.schema namespace. It seems that the offending line was the value of the :subname key in the db-spec.
:subname (str (io/resource-path) db-store)
It seems as though the h2 no longer likes the call to noir.io/resource-path.
I changed the line to be:
:subname (str "~/hard-path" db-store)
and I no longer get the exception. I didn't submit a pull request because I'm not sure if this is a safe change or if I'm making another mistake somewhere else. This particular code segment is relevant to the skeleton code generated by the
lein new luminus [myapp] +h2
templateWondering what your thoughts on this change are. Thanks again for all your help.