4

I am attempting to distribute a small web application build with the clojure web framework noir. It works as expected when run 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 runs, but every page results in a 404. My project.clj is the default one generated by lein noir new except I added :omit-source true and :aot :all.

I'm using:

leiningen 1.7.1

clojure 1.2.1

noir 1.2.1

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

  • Why does it not work (every page returns 404) when I move the jar file to another location (on the same computer)? – user1781292 Oct 28 '12 at 19:53

2 Answers2

0

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

  lein clean
  lein compile

and make sure you see each of your classes being built

Arthur Ulfeldt
  • 90,827
  • 27
  • 201
  • 284
0

I believe the problem you are experiencing is because of the way noir.server/load-views requires the namespaces. If you move it from the target/ directory, it can no longer find the views directory you passed into load-views.

The workaround is to explicitly require all you're views in lieu of using the load-views function. Then you should be able run the uberjar anywhere.

Trevor Bernard
  • 992
  • 10
  • 13