ClassNotFoundException and ClassCastException with lein-droid - clojure

When building a lein-droid project with [clj-http "0.7.7"] as a dependency in project.clj, it fails with the following error [0]:
Compiling cheshire.jsonp
Exception in thread "main" java.lang.ClassNotFoundException: javax.json.Json, compiling:(jsonp.clj:1:1)
[...]
Caused by: java.lang.ClassNotFoundException: javax.json.Json
[...]
Replacing the dependency with [cheshire "5.2.0"] (current version) produces the same error. Lowering the version to "5.1.1" removes this error.
Adding [clj-http "0.7.7"] as a dependency to the project introduces a new error [1]:
Compiling clj-http.conn-mgr
Exception in thread "main" java.lang.ClassCastException clj_http.conn_mgr$fn$reify__20 cannot be cast to java.security.KeyStore, compiling:(conn_mgr.clj:13:3)
[...]
Caused by: java.lang.ClassCastException: clj_http.conn_mgr$fn$reify__20 cannot be cast to java.security.KeyStore
[...]
Relevant settings from project.clj (set from the lein-droid tutorial):
:javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"]
:android { ...
:target-version "16"
...}
Changing these settings to the current version numbers doesn't change the error.
With cheshire 5.2.0
» lein deps :tree
WARNING!!! possible confusing dependencies found:
[clojure-complete "0.2.3"]
overrides
[clojure-complete "0.2.3"]
[cheshire "5.1.1"]
overrides
[clj-http "0.7.7"] -> [cheshire "5.2.0"]
Without cheshire in dependencies
» lein deps :tree
WARNING!!! possible confusing dependencies found:
[org.clojure/data.json "0.2.3"] -> [org.clojure/clojure "1.4.0"]
overrides
[clj-http "0.7.7"] -> [cheshire "5.2.0"] -> [tigris "0.1.1"] -> [org.clojure/clojure "1.5.1"]
[clojure-complete "0.2.3"]
overrides
[clojure-complete "0.2.3"]

Related

jlink fails on ring-json 0.5.1

I have a small Clojure project with /project.clj:
(defproject testjackson "0.1.0-SNAPSHOT"
:main testjackson.core
:dependencies [[org.clojure/clojure "1.10.3"]
[ring/ring-json "0.5.0"]])
and /src/testjackson/core.clj:
(ns testjackson.core
(:gen-class)
(:require [ring.middleware.json :refer [wrap-json-body]]))
(defn -main [& _] (println :testing wrap-json-body))
When I run it, it just prints:
$ java -jar target/testjackson-0.1.0-SNAPSHOT-standalone.jar
:testing #object[ring.middleware.json$wrap_json_body 0x37cd92d6 ring.middleware.json$wrap_json_body#37cd92d6]
It runs as expected. I can also execute jdeps on the uberjar to get the list of used modules:
$ jdeps --print-module-deps --ignore-missing-deps target/testjackson-0.1.0-SNAPSHOT-standalone.jar
java.base,java.desktop,java.sql,jdk.unsupported
However, when I bump ring-json version to 0.5.1, the jdeps call fails:
$ jdeps --print-module-deps --ignore-missing-deps target/testjackson-0.1.0-SNAPSHOT-standalone.jar
Exception in thread "main" java.lang.module.FindException: Module com.fasterxml.jackson.core not found, required by com.fasterxml.jackson.dataformat.smile
at java.base/java.lang.module.Resolver.findFail(Resolver.java:877)
at java.base/java.lang.module.Resolver.resolve(Resolver.java:191)
at java.base/java.lang.module.Resolver.resolve(Resolver.java:140)
at java.base/java.lang.module.Configuration.resolve(Configuration.java:422)
at java.base/java.lang.module.Configuration.resolve(Configuration.java:256)
at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:564)
at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:603)
at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:557)
at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:533)
at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:49)
How can this be fixed in the context of this small example program?
As near I as can find from searching, jdeps is from way back in Java 9. In fact, the version on my computer won't even accepts the 2 flags you used in the example, and it doesn't even have a --version option. Web searching shows no obvious uses for clojure.
What is the goal here? Your plain code works fine for me:
project.clj deps
:dependencies [
[org.clojure/clojure "1.11.1"]
[prismatic/schema "1.2.1"]
[ring/ring-json "0.5.1"]
[tupelo "22.05.24b"]
]
:plugins [[com.jakemccrary/lein-test-refresh "0.25.0"]
[lein-ancient "0.7.0"]
]
code
(ns demo.core
(:use tupelo.core)
(:require [ring.middleware.json :refer [wrap-json-body]])
(:gen-class))
(defn -main [& _]
(spyx (type wrap-json-body)))
and results
> lein clean ; lein run
(type wrap-json-body) => ring.middleware.json$wrap_json_body
Speculation
Although my jlink doesn't seem to work right, I can guess a little. Looking at project.clj, we can ask for a tree of depencencies:
> lein deps :tree
[nrepl "0.8.3" :exclusions [[org.clojure/clojure]]]
[org.clojure/clojure "1.11.1"]
[org.clojure/core.specs.alpha "0.2.62"]
[org.clojure/spec.alpha "0.3.218"]
[org.nrepl/incomplete "0.1.0" :exclusions [[org.clojure/clojure]]]
[prismatic/schema "1.2.1"]
[ring/ring-json "0.5.1"]
[cheshire "5.10.0"]
[com.fasterxml.jackson.core/jackson-core "2.10.2"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.10.2"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.10.2"]
[tigris "0.1.2"]
[ring/ring-core "1.9.2"]
[commons-fileupload "1.4"]
[commons-io "2.6"]
[crypto-equality "1.0.0"]
[crypto-random "1.2.0"]
[ring/ring-codec "1.1.3"]
[commons-codec "1.15"]
So we see that ring-json needs cheshire, which needs jackson.
Going back to ring-json 0.5.0 we see different version of cheshire and jackson:
> lein deps :tree
[nrepl "0.8.3" :exclusions [[org.clojure/clojure]]]
[org.clojure/clojure "1.11.1"]
[org.clojure/core.specs.alpha "0.2.62"]
[org.clojure/spec.alpha "0.3.218"]
[org.nrepl/incomplete "0.1.0" :exclusions [[org.clojure/clojure]]]
[prismatic/schema "1.2.1"]
[ring/ring-json "0.5.0"]
[cheshire "5.9.0"]
[com.fasterxml.jackson.core/jackson-core "2.9.9"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.9.9"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.9.9"]
[tigris "0.1.1"]
[ring/ring-core "1.7.1"]
[clj-time "0.14.3"]
[joda-time "2.9.9"]
[commons-fileupload "1.3.3"]
[commons-io "2.6"]
[crypto-equality "1.0.0"]
[crypto-random "1.2.0"]
[ring/ring-codec "1.1.1"]
[commons-codec "1.11"]
Note that you can force newer versions in project.clj if you want. Just manually require cheshire and jackson, and put them near the top!
:dependencies [
; priority 1 libs
[org.clojure/clojure "1.11.1"]
[cheshire "5.10.2"]
[com.fasterxml.jackson.core/jackson-core "2.13.3"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.13.3"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.13.3"]
; priority 2 libs
[prismatic/schema "1.2.1"]
[ring/ring-json "0.5.0"]
; [tupelo "22.05.24b"]
]
with result
> lcr
time (lein do clean, run)
:type ring.middleware.json$wrap_json_body
8.11s user 0.59s system 218% cpu 3.989 total
~/expr/demo >
~/expr/demo >
~/expr/demo > lein deps :tree
[cheshire "5.10.2"]
[tigris "0.1.2"]
[com.fasterxml.jackson.core/jackson-core "2.13.3"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.13.3"]
[com.fasterxml.jackson.core/jackson-databind "2.13.3"]
[com.fasterxml.jackson.core/jackson-annotations "2.13.3"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.13.3"]
[nrepl "0.8.3" :exclusions [[org.clojure/clojure]]]
[org.clojure/clojure "1.11.1"]
[org.clojure/core.specs.alpha "0.2.62"]
[org.clojure/spec.alpha "0.3.218"]
[org.nrepl/incomplete "0.1.0" :exclusions [[org.clojure/clojure]]]
[prismatic/schema "1.2.1"]
[ring/ring-json "0.5.0"]
[ring/ring-core "1.7.1"]
[clj-time "0.14.3"]
[joda-time "2.9.9"]
[commons-fileupload "1.3.3"]
[commons-io "2.6"]
[crypto-equality "1.0.0"]
[crypto-random "1.2.0"]
[ring/ring-codec "1.1.1"]
[commons-codec "1.11"]
Perhaps something similar will solve your problem. It has been crucial for me in the past.
Specifically, the jackson libs absolutely must
have all 3 sub-libraries on the same version. Because dependent libs
often don't update their own deps like jackson as often as they could, it is easy to get version conflicts when 2 or more libs each require different versions of jackson. The above technique of forcing a specific version of jackson (or any other lib) is a lifesaver. IMHO, it is also much better than trying to put in a bunch of lein :exclusions clauses.

Compojure with Datomic won't compile

I'm setting up a compojure app, and I want to have datomic as my database - but as soon as I add the client-pro dependency, my app won't run.
Here's what I did:
Registered for an account
Downloaded datomic-pro
Created a transactor.properties and updated it with the license-key I received on my email
Ran bin/transactor transactor.properties
Opened another tab, and created a database:
(require ‘[datomic.api :as d])
(def db-uri “datomic:dev://localhost:4334/hello”)
(d/create-database db-uri)
Started a peer server on another tab
bin/run -m datomic.peer-server -h localhost -p 8998 -a myaccesskey,mysecret -d hello,datomic:dev://localhost:4334/hello
Added [com.datomic/client-pro “0.8.28”] to my dependencies
When running lein ring server I am getting this error:
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.thread.NonBlockingThread
A Quick Aside
Not a direct answer, but if you are just looking for a fast start with Datomic, you can clone the Tupelo Datomic repo here:
https://github.com/cloojure/tupelo-datomic
It includes a pre-configured version of Datomic Free. Just run lein test to see it in action. You can then add your own code.
Regarding Jetty
The answer from Erwin may be all you need. Another possibility is that you may need to add in transitive dependencies at specific versions, and use :exclude on others. Please also note that in project.clj important deps MUST be listed at the top of the file, as these deps versions (and their transitive deps versions) WILL OVERRIDE any deps versions specified later.
I have lein deps for one project that look like this in project.clj:
:exclusions [cheshire
com.cognitect/transit-clj
com.cognitect/transit-cljs
com.cognitect/transit-java
com.cognitect/transit-js
com.fasterxml.jackson.core/jackson-core
com.fasterxml.jackson.core/jackson-databind
com.fasterxml.jackson.dataformat/jackson-dataformat-cbor
com.fasterxml.jackson.dataformat/jackson-dataformat-smile
joda-time/joda-time
org.eclipse.jetty/jetty-server]
:dependencies [
; fundamental items must come first to override later transitive dependencies
[cheshire "5.8.1"]
[com.cognitect/transit-clj "0.8.313"]
[com.cognitect/transit-cljs "0.8.256"]
[com.cognitect/transit-java "0.8.337"]
[com.cognitect/transit-js "0.8.861"]
[com.fasterxml.jackson.core/jackson-core "2.9.9"]
[com.fasterxml.jackson.core/jackson-databind "2.9.9"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-cbor "2.9.9"]
[com.fasterxml.jackson.dataformat/jackson-dataformat-smile "2.9.9"]
[joda-time/joda-time "2.10.3"]
[org.clojure/clojure "1.10.1"]
[org.eclipse.jetty/jetty-server "9.4.19.v20190610"]
then a list of 2nd-tier deps:
; high-priority libs, ensure these versions override any transitive dependency versions
[binaryage/devtools "0.9.10"]
[binaryage/oops "0.7.0"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[com.cemerick/url "0.1.1"]
[org.clojure/core.async "0.4.500" :exclusions [org.clojure/tools.reader]]
[org.clojure/core.match "0.3.0"]
[org.clojure/test.check "0.9.0"]
[org.clojure/tools.cli "0.4.2"]
[org.clojure/tools.logging "0.5.0"]
[org.clojure/tools.nrepl "0.2.13"] ; #todo #awt upgrade => [nrepl "0.3.1"] from https://github.com/nrepl/nrepl
[prismatic/schema "1.1.11"]
[tupelo "0.9.144"]
[venantius/accountant "0.2.4"]
then 3nd-tier deps:
; "normal" dependency libs, whose transitive dependencies can be overridden by previous libs
[ch.qos.logback/logback-classic "1.2.3"]
[clj-http "3.10.0"]
[clj-time "0.15.1"] ; #todo switch to java.time & tupelo.java-time
[cljsjs/cytoscape "3.1.4-0"]
[com.amazonaws/aws-java-sdk "1.11.602" :exclusions [joda-time]]
[com.taoensso/carmine "2.19.1"]
[compojure "1.6.1"]
[cprop "0.1.14"]
[expound "0.7.2"]
[funcool/struct "1.4.0"]
[io.janusplatform/janus-environment-config "1.8.7-SNAPSHOT"]
[io.janusplatform/janus-logging-java "1.0.11-SNAPSHOT" :exclusions [com.google.guava/guava]]
[io.janusplatform/janus-resource-connector "4.3.0-SNAPSHOT"]
[jayq "2.5.5"]
[luminus-jetty "0.1.7" ]
[luminus-nrepl "0.1.6"]
[luminus/ring-ttl-session "0.3.3"]
[markdown-clj "1.10.0"]
[metosin/muuntaja "0.2.1"]
[metosin/ring-http-response "0.9.1"]
[metosin/spec-tools "0.10.0"]
[metosin/scjsv "0.5.0"]
[metrics-clojure-ring "2.10.0"]
[mount "0.1.16"]
[org.webjars/bootstrap "4.3.1"]
[org.webjars/font-awesome "5.9.0"]
[overtone/at-at "1.2.0"]
[ring-webjars "0.2.0"]
[ring/ring-codec "1.1.2"]
[ring/ring-core "1.7.1"]
[ring/ring-defaults "0.3.2"]
[ring/ring-json "0.4.0"]
[throttler "1.0.0"]
and some misc deps:
[amazonica "0.3.145" :exclusions [com.amazonaws/aws-java-sdk
com.fasterxml.jackson.core/jackson-core
com.fasterxml.jackson.dataformat/jackson-dataformat-cbor
org.apache.httpcomponents/httpclient]] ; #todo do we really need all these exclusions???
[cljs-ajax "0.8.0" :exclusions [cheshire
com.cognitect/transit-clj
com.cognitect/transit-java
org.apache.httpcomponents/httpasyncclient
org.apache.httpcomponents/httpcore
org.msgpack/msgpack]] ; #todo do we really need all these exclusions???
[org.springframework/spring-webmvc "5.1.8.RELEASE" :exclusions [org.springframework/spring-jcl
org.springframework/spring-aop]]
]
You can also see I had to exclude Jetty to prevent a transitive dependency from pulling in the wrong version, then specifically add in the version I wanted.

How do I use cljsjs packages in my chestnut application?

I'm trying to use cljsjs/moment with an existing chestnut template app, but I get the following from figwheel
No such namespace: cljsjs.moment, could not locate cljsjs/moment.cljs, cljsjs/moment.cljc, or Closure namespace "cljsjs.moment"
Please see src/cljs/some_awesome_app/system.cljs
My dependencies:
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.854" :scope "provided"]
[com.cognitect/transit-clj "0.8.300"]
[ring "1.6.2"]
[ring/ring-defaults "0.3.1"]
[bk/ring-gzip "0.2.1"]
[radicalzephyr/ring.middleware.logger "0.6.0"]
[compojure "1.6.0"]
[environ "1.1.0"]
[com.stuartsierra/component "0.3.2"]
[org.danielsz/system "0.4.0"]
[org.clojure/tools.namespace "0.2.11"]
[org.omcljs/om "1.0.0-alpha48"]
[clj-http "3.7.0"]
[hiccup "2.0.0-alpha1"]
[cheshire "5.8.0"]
[cljsjs/moment "2.17.1-1"]] ;; <--- here it is
My main file:
(ns some-awesome-app.system
(:require [com.stuartsierra.component :as component]
[cljsjs.moment]
[some-awesome-app.components.ui :refer [new-ui-component]]))
I'm getting that error, without even using the library in my code..
Figured it out.
I'm using spacemacs with CIDER. And I was using jack-in instead of jack-in-clojurescript.
All works fine now.

Problems creating an executeable for a luminus clojure project

I am building a server program to provide an API to a mongo database containing details of photos. All works well running it from the REPL, or if I start it using lein run.
The problems happen when I try and run the uberjar. Building the uberjar works ok:
(master) photo-api: lein uberjar
Compiling photo-api.env
Compiling photo-api.config
Compiling photo-api.core
WARNING: find-keyword already refers to: #'clojure.core/find-keyword in namespace: image-lib.core, being replaced by: #'image-lib.core/find-keyword
Compiling photo-api.db.core
Compiling photo-api.handler
Compiling photo-api.layout
Compiling photo-api.middleware
Compiling photo-api.routes.home
Compiling photo-api.routes.services
Created /Users/iain/Code/Clojure/Luminus/photo-api/target/uberjar/photo-api-0.1.0-SNAPSHOT.jar
Created /Users/iain/Code/Clojure/Luminus/photo-api/target/uberjar/photo-api.jar
(master) photo-api:
but running the jar gives an error:
(master) photo-api: java -jar target/uberjar/photo-api.jar
WARNING: find-keyword already refers to: #'clojure.core/find-keyword in namespace: image-lib.core, being replaced by: #'image-lib.core/find-keyword
read config from resource: "config.edn"
Exception in thread "main" java.lang.RuntimeException: could not start [#'photo-api.db.core/db*] due to
at mount.core$up$fn__420.invoke(core.cljc:92)
at mount.core$up.invokeStatic(core.cljc:92)
at mount.core$up.invoke(core.cljc:90)
at mount.core$bring.invokeStatic(core.cljc:210)
at mount.core$bring.invoke(core.cljc:202)
at mount.core$start.invokeStatic(core.cljc:252)
at mount.core$start.doInvoke(core.cljc:244)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at mount.core$start_with_args.invokeStatic(core.cljc:350)
at mount.core$start_with_args.doInvoke(core.cljc:346)
at clojure.lang.RestFn.invoke(RestFn.java:410)
at photo_api.core$start_app.invokeStatic(core.clj:42)
at photo_api.core$start_app.invoke(core.clj:41)
at photo_api.core$_main.invokeStatic(core.clj:50)
at photo_api.core$_main.doInvoke(core.clj:49)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at photo_api.core.main(Unknown Source)
Caused by: java.lang.NullPointerException
at com.mongodb.ConnectionString.<init>(ConnectionString.java:222)
at com.mongodb.MongoClientURI.<init>(MongoClientURI.java:189)
at com.mongodb.MongoClientURI.<init>(MongoClientURI.java:171)
at monger.core$connect_via_uri.invokeStatic(core.clj:230)
at monger.core$connect_via_uri.invoke(core.clj:230)
at photo_api.db.core$fn__12620.invokeStatic(core.clj:29)
at photo_api.db.core$fn__12620.invoke(core.clj:28)
at mount.core$record_BANG_.invokeStatic(core.cljc:86)
at mount.core$record_BANG_.invoke(core.cljc:85)
at mount.core$up$fn__420.invoke(core.cljc:93)
... 18 more
Or the SNAPSHOT jar.
(master) photo-api: java -jar target/uberjar/photo-api-0.1.0-SNAPSHOT.jar
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/Var
at photo_api.core.<clinit>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: clojure.lang.Var
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
(master) photo-api:
What am I missing here? I'm guessing it's something to do with dev build and production build differences, but I can't spot anything obvious and the error messages are not a lot of help to me.
This is the project file which as far as I remember is mostly straight from the original luminus template:
(defproject photo-api "0.1.0-SNAPSHOT"
:description "API for geting data from photos db"
:url "http://soulflyer.com"
:dependencies [[cider/cider-nrepl "0.14.0"]
[clj-time "0.13.0"]
[com.google.guava/guava "20.0"]
[com.novemberain/monger "3.1.0" :exclusions [com.google.guava/guava]]
[compojure "1.6.0"]
[cprop "0.1.10"]
[funcool/struct "1.0.0"]
[luminus-immutant "0.2.3"]
[luminus-nrepl "0.1.4"]
[luminus/ring-ttl-session "0.3.2"]
[markdown-clj "0.9.99"]
[metosin/compojure-api "1.1.10"]
[metosin/muuntaja "0.3.1"]
[metosin/ring-http-response "0.9.0"]
[mount "0.1.11"]
[org.clojure/clojure "1.8.0"]
[org.clojure/tools.cli "0.3.5"]
[org.clojure/tools.logging "0.4.0"]
[org.clojure/data.json "0.2.6"]
[org.webjars.bower/tether "1.4.0"]
[org.webjars/bootstrap "4.0.0-alpha.5"]
[org.webjars/font-awesome "4.7.0"]
[org.webjars/jquery "3.1.1"]
[ring-webjars "0.2.0"]
[ring/ring-core "1.6.1"]
[ring/ring-defaults "0.3.0"]
[selmer "1.10.7"]
[image-lib "0.2.1-SNAPSHOT"]]
:min-lein-version "2.0.0"
:jvm-opts ["-server" "-Dconf=.lein-env"]
:source-paths ["src/clj"]
:test-paths ["test/clj"]
:resource-paths ["resources"]
:target-path "target/%s/"
:main ^:skip-aot photo-api.core
:plugins [[lein-cprop "1.0.3"]
[org.clojars.punkisdead/lein-cucumber "1.0.5"]
[lein-immutant "2.1.0"]]
:cucumber-feature-paths ["test/clj/features"]
:profiles
{:uberjar {:omit-source true
:aot :all
:uberjar-name "photo-api.jar"
:source-paths ["env/prod/clj"]
:resource-paths ["env/prod/resources"]}
:dev [:project/dev :profiles/dev]
:test [:project/dev :project/test :profiles/test]
:project/dev {:dependencies [[prone "1.1.4"]
[ring/ring-mock "0.3.0"]
[ring/ring-devel "1.6.1"]
[pjstadig/humane-test-output "0.8.2"]
[clj-webdriver/clj-webdriver "0.7.2"]
[org.apache.httpcomponents/httpcore "4.4"]
[org.clojure/core.cache "0.6.3"]
[org.seleniumhq.selenium/selenium-server "2.48.2"]]
:plugins [[com.jakemccrary/lein-test-refresh "0.19.0"]
[refactor-nrepl "2.3.0-SNAPSHOT"]]
:source-paths ["env/dev/clj"]
:resource-paths ["env/dev/resources"]
:repl-options {:init-ns user}
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]}
:project/test {:resource-paths ["env/test/resources"]}
:profiles/dev {}
:profiles/test {}})
I think you're just missing required configuration - at least Mongo connection string.
When running in dev mode, the luminus (and cprops configuration library) uses the config from your profiles.clj.
However, this is the leiningen thing and it's not available when running from uberjar.
You can specify all your "production" configuration in "config.edn" file and run uberjar like this:
java -Dconf=config.edn -jar target/uberjar/photo-api.jar
You can also use java system properties to set configuration values one by one.
See http://www.luminusweb.net/docs/environment.md for more details.

Compiling in Clojure - Redis/Carmine

I have problem with the Carmine uberjar compile (lein with-profile embed uberjar). Maybe very easy the answer, but I didn't get any help from other forums. The lein ring server-headless 8080 run correctly. If I run this command lein with-profile embed uberjar, then I got this error message. Could you help me, what is the correct setup?
Thanks in advance,
RRR
(defproject fu "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:min-lein-version "2.0.0"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[ring "1.3.2"]
[compojure "1.5.1"]
[ring/ring-defaults "0.2.1"]
[hiccup "1.0.5"]
[selmer "1.10.3"]
[com.cemerick/friend "0.2.0"]
[de.ubercode.clostache/clostache "1.4.0"]
[com.taoensso/carmine "2.15.0"]]
:main fu.handler
:plugins [[lein-ring "0.9.7"]]
:ring {:handler fu.handler/app
:auto-reload? true
:auto-refresh? true}
:aot [fu.handler]
:uberjar-name "fu-example-default.jar"
:profiles {
:provided {:dependencies [[nginx-clojure "0.4.4"]]}
:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring/ring-mock "0.3.0"]]}
:embed {:dependencies
[[nginx-clojure/nginx-clojure-embed "0.4.4"]]
:aot [fu.handler]
:main fu.handler
:uberjar-name "fu-example-embed.jar"
}
})
​
ERROR message:
​lein with-profile embed uberjar
WARNING: You're currently running as root; probably by accident.
Press control-C to abort or Enter to continue as root.
Set LEIN_ROOT to disable this warning.
​
Compiling fu.handler
Compiling fu.handler
nil
Exception in thread "main" java.lang.ExceptionInInitializerError, compiling:(/tmp/form-init8960082151990763547.clj:1:73)
at clojure.lang.Compiler.load(Compiler.java:7391)
at clojure.lang.Compiler.loadFile(Compiler.java:7317)
at clojure.main$load_script.invokeStatic(main.clj:275)
at clojure.main$init_opt.invokeStatic(main.clj:277)
at clojure.main$init_opt.invoke(main.clj:277)
at clojure.main$initialize.invokeStatic(main.clj:308)
at clojure.main$null_opt.invokeStatic(main.clj:342)
at clojure.main$null_opt.invoke(main.clj:339)
at clojure.main$main.invokeStatic(main.clj:421)
at clojure.main$main.doInvoke(main.clj:384)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at clojure.lang.RT.classForName(RT.java:2168)
at clojure.lang.RT.classForName(RT.java:2177)
at clojure.lang.RT.loadClassForName(RT.java:2196)
at clojure.lang.RT.load(RT.java:443)
at clojure.lang.RT.load(RT.java:419)
at clojure.core$load$fn__5677.invoke(core.clj:5893)
at clojure.core$load.invokeStatic(core.clj:5892)
at clojure.core$load.doInvoke(core.clj:5876)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invokeStatic(core.clj:5697)
at clojure.core$compile$fn__5682.invoke(core.clj:5903)
at clojure.core$compile.invokeStatic(core.clj:5903)
at clojure.core$compile.invoke(core.clj:5895)
at user$eval20$fn__29.invoke(form-init8960082151990763547.clj:1)
at user$eval20.invokeStatic(form-init8960082151990763547.clj:1)
at user$eval20.invoke(form-init8960082151990763547.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6927)
at clojure.lang.Compiler.eval(Compiler.java:6917)
at clojure.lang.Compiler.eval(Compiler.java:6917)
at clojure.lang.Compiler.load(Compiler.java:7379)
... 14 more
Caused by: java.lang.ClassCastException: taoensso.carmine.protocol.Context cannot be cast to taoensso.carmine.protocol.Context
at taoensso.carmine.commands$enqueue_request.invokeStatic(commands.clj:211)
at taoensso.carmine.commands$enqueue_request.invoke(commands.clj:196)
at taoensso.carmine$keys.invokeStatic(carmine.clj:128)
at taoensso.carmine$keys.invoke(carmine.clj:128)
at fu.handler$fn__8942$fn__8943$fn__8944.invoke(handler.clj:35)
at taoensso.carmine.protocol$_with_replies.invokeStatic(protocol.clj:340)
at taoensso.carmine.protocol$_with_replies.invoke(protocol.clj:328)
at fu.handler$fn__8942$fn__8943.invoke(handler.clj:35)
at fu.handler$fn__8942.invokeStatic(handler.clj:35)
at fu.handler$fn__8942.invoke(handler.clj:35)
at fu.handler__init.load(Unknown Source)
at fu.handler__init.<clinit>(Unknown Source)
... 36 more
Compilation failed: Subprocess failed
Uberjar aborting because jar failed: Compilation failed: Subprocess failed
Error encountered performing task 'uberjar' with profile(s): 'embed'
Uberjar aborting because jar failed: Compilation failed: Subprocess failed
With monger I found what is the problem source. Redis can accept to use qualifield keywords eg. "#{::user}". But when compiled the script.. works like mongodb, can't read anymore keywords. You can write, but not read. Maybe that is a bug.. (by the way, just in case when we compiled with uberjar..)