This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-10
Channels
- # beginners (97)
- # boot (77)
- # cider (7)
- # cljs-dev (47)
- # cljsrn (3)
- # clojure (125)
- # clojure-austin (5)
- # clojure-dusseldorf (1)
- # clojure-italy (4)
- # clojure-russia (91)
- # clojure-spec (80)
- # clojure-uk (54)
- # clojurescript (92)
- # core-async (6)
- # cursive (17)
- # datomic (56)
- # hoplon (7)
- # immutant (3)
- # liberator (3)
- # luminus (4)
- # off-topic (26)
- # om (41)
- # om-next (11)
- # pedestal (3)
- # perun (3)
- # protorepl (25)
- # re-frame (32)
- # reagent (33)
- # ring (46)
- # rum (3)
- # spacemacs (5)
- # specter (82)
- # test-check (16)
- # untangled (8)
- # yada (26)
Hi. I am working on a cljs project. Figwheel runs it Awesomely. I want to make sure I can deploy this to my remote server when i'm all done, so I'm making sure lein ring uberjar
works as expected
However, when I make an uberjar and try java -jar target/nf-0.0.2-standalone.jar
... the server does start but accessing the root url gives the following error:
"Problem accessing /. Reason: java.lang.NullPointerException"
So I get a 500 response and I don't know why.
My :figwheel line in my >project.clj
looks like :figwheel {:ring-handler nf.core/handler}
and my :ring line looks very similar...
:ring {:handler nf.core/handler :port 8440}
but the lein ring uberjar
... no dice ... lil help?
sova: How are you compiling your production cljs code? cljsbuild?
@weavejester I totally forgot about that step.
I just tried lein cljsbuild once
but I still get the same error after packing up the uberjar...
You need to have a :cljsbuild
key in your project file, and you need to build your JS as part of your compilation.
Let me dig out an example
Ah, give me a few minutes.
Okay no stress. Thanks a lot
I have a pretty good idea of what that looks like..
based on..
it's great because everything loads perfectly with lein figwheel
but i'm losing something in translation..
@weavejester hey it works now
thanks for your good juju haha
(by the way, thanks a lot for ring and all the awesome work you do, i'm a big fan.)
Sorry for the delay. Do you have keys like:
:resource-paths ["resources" "target/cljsbuild"]
:prep-tasks [["javac"] ["cljsbuild" "once"] [”compile"]]
Aum... I have a :resource-paths ["resources"] ... I shall add the prep-tasks one now
Because to make it work consistently, you need to ensure that the code is built in the prep-tasks before the jar, and that the cljs code you build is somewhere on the resource path
Gotcha. So those lines make sure the cljs gets compiled and added?
Yeah, as long as your compile target for cljsbuild is “target/cljsbuild"
Yours might be different.
It is different. :output-to "resources/public/js/nf_app.js" :output-dir "resources/public/js/out" ...
would it then be :resource-paths ["resources" "resources/public/js"]
?
Oh, there’s no need because “resources” covers “resources/public/js"
Ah, ok. Very good
So you’re fine. You just need to either manually call cljsbuild once
before every build, or add it to a prep-task
Awesome!
Thank you so much
I love working with Clojure and Cljs because typically when you get something working you never have to touch it again haha
I also tend to have a line like:
:profiles {:repl {:prep-tasks ^:replace [["javac"] [”compile”]]}}
Because that ensures that starting the REPL doesn’t recompile my cljs.
Interesting! So that makes sure that when you run lein repl
it doesn't do the cljs prep-task... that's good to have & know
man there are so many possibilities for project.clj ... is crazey
Yep. Because I have Figwheel to do that, I only want to have the cljbuild happen during lein uberjar
or lein run
.
Supersweet. Thanks very much for your help dear sir.