Noir uberjar only works in the build directory

I am trying to distribute a small build of web applications using clojure web framework noir. It works as expected when starting with lein run . When I run lein uberjar and then java -jar project-1.0.0-standalone.jar , it works as expected. However, if I move the jar file (project-1.0.0-standalone.jar), it starts, but each page leads to 404. My project.clj is the default value generated by lein noir new , except that I added :omit-source true and :aot :all .

I use:

leiningen 1.7.1

clojure 1.2.1

noir 1.2.1

How can I create a jar that can be distributed to others without a source?

+4
source share
2 answers

if you have not added gen-class calls to namespace definitions by adding them, this may fix it. You can verify this by running

  lein clean lein compile 

and make sure that you see each of the built classes

0
source

I believe the problem you are having is that noir.server / load-views requires a namespace. If you move it from the target / directory, it will no longer be able to find the views directory that you passed to the load views.

The workaround is to explicitly require all your views instead of using the load-views function. Then you can run uberjar anywhere.

0
source

Source: https://habr.com/ru/post/1442627/


All Articles