I have been working with Clojure now some of the time for the last 18
months, so I am no longer a complete noob. But I still have many questions
about how to work at the REPL. In particular, I don't understand how the
REPL interacts with the class path.
I have an app that is working. When I need to make changes to it, my
workflow goes like this:
1.) start emacs
2.) open a file in the project that I want to work in. I usually start by
opening up the project.clj fie.
3.) type nrepl-jack-in to launch the repl.
4.) load whatever file holds the (main-) function that starts the app. So
for me, for instance, it might be:
(load-file “src/admin/core.clj”)
5.) switch to that namespace:
(in-ns ‘admin.core)
6.) call the function that starts my app: (main-). Give it any arguments
that it needs.
7.) do work. Moving around inside of the project tends to consist of a lot
of loading a file:
(load-file “src/admin/controller.clj”)
and then switching to the namespace:
(in-ns ‘admin.controller)
However, I have a config file at:
/resources/config/schema.edn
If I open a terminal, cd to the top level of the directories where this app
lives, and then run "lein uberjar" I get an app that works just fine if I
do:
java -jar admin-1-standalone.jar
But when I want to work on this app at the REPL, the app seems unable to
find the schema.edn file. You can see my REPL session below. The
function (initiate-forms) has this line:
(read-string (slurp (clojure.java.io/resource "config/schema.edn")))
This should run when the app starts and then it is stored in
secretary/interactions, but below you can see that secretary/interactions
is empty.
Why does this work when I run the app from the command line? What do I need
to do to get this work when I'm in the REPL? I am assuming the problem here
has something to do with the classpath, please tell me if I'm wrong.
admin.controller> (load-file "src/admin/core.clj")
#'admin.core/-main
admin.controller> (in-ns 'admin.core)
#<Namespace admin.core>
admin.core> (ns-publics 'admin.core)
{-main #'admin.core/-main}
admin.core> (-main "35000")
App 'TMA admin' is starting.
If no port is specified then we will default to port 34000.
You can set this app to production mode, where debugging output to the
terminal is surpressed, by starting it like this:
java -jar target/admin-1-standalone.jar 30001 production
#<Server org.eclipse.jetty.server.Server@70faf7c7>
admin.core> (load-file "src/admin/secretary.clj")
{:dire/error-handlers {java.lang.NullPointerException
#<secretary$eval1798$fn__1799 admin.secretary$eval1798$fn__1799@7a4311f9>},
:ns #<Namespace admin.queries>, :name process-some-fetch-function,
:arglists ([function-to-call-to-get-data-from-monger map-for-queries]),
:column 1, :line 124, :file "admin/queries.clj"}
admin.core> (in-ns 'admin.secretary)
#<Namespace admin.secretary>
admin.secretary> interactions
#<Atom@4d1fafe8: {}>
admin.secretary> @interactions
{}
admin.secretary> (load-file "src/admin/startup.clj")
#'admin.startup/start-channels
admin.secretary> (in-ns 'admin.startup)
#<Namespace admin.startup>
admin.startup> (ns-publics 'admin.startup)
{start-channels #'admin.startup/start-channels, initiate-forms
#'admin.startup/initiate-forms, connect-to-database
#'admin.startup/connect-to-database, set-the-current-debugging-level
#'admin.startup/set-the-current-debugging-level}
admin.startup> (start-channels)
nil
admin.startup> (initiate-forms)
cannot read object
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.