java.lang.ClassNotFoundException: sun.misc.Launcher when running boot repl - clojure

I'm trying to run boot repl and I get the following error.
java.lang.Thread.run Thread.java: 832
java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java: 630
java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java: 1130
java.util.concurrent.FutureTask.run FutureTask.java: 264
...
clojure.core/binding-conveyor-fn/fn core.clj: 1938
Skipped a lot of lines here
java.lang.ClassLoader.loadClass ClassLoader.java: 589
...
java.net.URLClassLoader.findClass URLClassLoader.java: 435
java.lang.ClassNotFoundException: sun.misc.Launcher
clojure.lang.ExceptionInfo: sun.misc.Launcher

I was following a guide on how to set up boot from spacemacs. The information there was outdated or wrong. The problem was that in my ~/.boot/profile.boot To solve the issue I had to change dependencies from what was on spacemacs site to what was on refactor-nrepl.
(require 'boot.repl)
(swap! boot.repl/*default-dependencies* conj
'[refactor-nrepl "2.5.1"]
'[cider/cider-nrepl "0.25.9"])
(swap! boot.repl/*default-middleware* conj
'refactor-nrepl.middleware/wrap-refactor)

Related

Clojurescript repl trying to invoke Clojure function from the Transit library

I have both the cognitect.transit-clj and cognitect.transit-cljs dependencies because my project is Clojure on the backend and CLJS on the frontend. I'm connecting to a shadow-cljs repl in cider with cider-connect.
In the repl, I do:
(require '[cognitect.transit :as xit])
(def my-writer (xit/writer :json))
I get this error:
Execution error (ArityException) at nrepl.middleware.interruptible-eval/evaluate$fn (interruptible_eval.clj:91).
Wrong number of args (1) passed to: cognitect.transit/writer
It appears that it's trying to invoke the java version of transmit/writer. Is something wrong with my dependencies or setup?
Here's the full stack trace:
clojure.lang.Compiler$CompilerException: Syntax error macroexpanding at (NO_SOURCE_FILE:45:29).
#:clojure.error{:phase :execution, :line 45, :column 29, :source "NO_SOURCE_FILE"}
at clojure.lang.Compiler$InvokeExpr.eval (Compiler.java:3707)
clojure.lang.Compiler$DefExpr.eval (Compiler.java:457)
clojure.lang.Compiler.eval (Compiler.java:7182)
clojure.lang.Compiler.eval (Compiler.java:7132)
clojure.core$eval.invokeStatic (core.clj:3214)
clojure.core$eval.invoke (core.clj:3210)
nrepl.middleware.interruptible_eval$evaluate$fn__42793.invoke (interruptible_eval.clj:91)
clojure.main$repl$read_eval_print__9086$fn__9089.invoke (main.clj:437)
clojure.main$repl$read_eval_print__9086.invoke (main.clj:437)
clojure.main$repl$fn__9095.invoke (main.clj:458)
clojure.main$repl.invokeStatic (main.clj:458)
clojure.main$repl.doInvoke (main.clj:368)
clojure.lang.RestFn.invoke (RestFn.java:1523)
nrepl.middleware.interruptible_eval$evaluate.invokeStatic (interruptible_eval.clj:84)
nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:56)
nrepl.middleware.interruptible_eval$interruptible_eval$fn__42819$fn__42823.invoke (interruptible_eval.clj:155)
clojure.lang.AFn.run (AFn.java:22)
nrepl.middleware.session$session_exec$main_loop__43068$fn__43072.invoke (session.clj:190)
nrepl.middleware.session$session_exec$main_loop__43068.invoke (session.clj:189)
clojure.lang.AFn.run (AFn.java:22)
java.lang.Thread.run (Thread.java:748)
Caused by: clojure.lang.ArityException: Wrong number of args (1) passed to: cognitect.transit/writer
at clojure.lang.AFn.throwArity (AFn.java:429)
clojure.lang.AFn.invoke (AFn.java:32)
clojure.lang.AFn.applyToHelper (AFn.java:154)
clojure.lang.AFn.applyTo (AFn.java:144)
clojure.lang.Compiler$InvokeExpr.eval (Compiler.java:3702)
clojure.lang.Compiler$DefExpr.eval (Compiler.java:457)
clojure.lang.Compiler.eval (Compiler.java:7182)
clojure.lang.Compiler.eval (Compiler.java:7132)
clojure.core$eval.invokeStatic (core.clj:3214)
clojure.core$eval.invoke (core.clj:3210)
nrepl.middleware.interruptible_eval$evaluate$fn__42793.invoke (interruptible_eval.clj:91)
clojure.main$repl$read_eval_print__9086$fn__9089.invoke (main.clj:437)
clojure.main$repl$read_eval_print__9086.invoke (main.clj:437)
clojure.main$repl$fn__9095.invoke (main.clj:458)
clojure.main$repl.invokeStatic (main.clj:458)
clojure.main$repl.doInvoke (main.clj:368)
clojure.lang.RestFn.invoke (RestFn.java:1523)
nrepl.middleware.interruptible_eval$evaluate.invokeStatic (interruptible_eval.clj:84)
nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:56)
nrepl.middleware.interruptible_eval$interruptible_eval$fn__42819$fn__42823.invoke (interruptible_eval.clj:155)
clojure.lang.AFn.run (AFn.java:22)
nrepl.middleware.session$session_exec$main_loop__43068$fn__43072.invoke (session.clj:190)
nrepl.middleware.session$session_exec$main_loop__43068.invoke (session.clj:189)
clojure.lang.AFn.run (AFn.java:22)
java.lang.Thread.run (Thread.java:748)
I do not know enough about cider-connect but it is very likely that you are just connected to the CLJ REPL and not the actual CLJS REPL you are looking for. A connection always starts out as CLJ and your editor has to "upgrade" it to CLJS. Maybe this is still current?
For plain shadow-cljs you get to the CLJS REPL directly via shadow-cljs cljs-repl app (assuming :app is your build id). For nREPL your editor is in control. I'm sure there is a command for that.

Why some namespaces can not be loaded by clojurescript browser repl?

I wrote some tests, I found that:
Only namespaces which is a dependency of my compiled clojurescript can be required in repl.
Namespaces which not refered by any compiled clojurescript can NOT be required in repl.
Is this the limitation of REPL? Or something wrong here?
When I require namespaces which not refered by any compiled clojurescript, I got error:
cljs.user> (require 'cljsjs.d3)
711cljs.core._STAR_print_namespace_maps_STAR_ = true
712Loading: (goog)
713Loading: (cljsjs.d3)
714goog.addDependency("base.js", [], []);
715goog.addDependency("../cljsjs/d3/development/d3.inc.js", [], []);
716
717goog.require('cljsjs.d3');
718null;
719
720"Error evaluating:" (require (quote cljsjs.d3)) :as "goog.require('cljsjs.d3');\nnull;\n"
721Error: goog.require could not find: cljsjs.d3
722Failed to canonicalize stacktrace
723clojure.lang.ExceptionInfo: Could not relativize URL http://192.168.124.5:9000/goog/base.js {:type :parse-stacktrace, :reason :relativize-url}
724 at clojure.core$ex_info.invokeStatic(core.clj:4617)
725 at clojure.core$ex_info.invoke(core.clj:4617)
726 at cljs.stacktrace$parse_file.invokeStatic(stacktrace.cljc:104)
727 at cljs.stacktrace$parse_file.invoke(stacktrace.cljc:81)
728 at cljs.stacktrace$chrome_st_el__GT_frame.invokeStatic(stacktrace.cljc:121)
729 at cljs.stacktrace$chrome_st_el__GT_frame.invoke(stacktrace.cljc:111)
730 at cljs.stacktrace$eval9220$fn__9221$fn__9222.invoke(stacktrace.cljc:142)
731 at clojure.core$map$fn__4785.invoke(core.clj:2646)
732 at clojure.lang.LazySeq.sval(LazySeq.java:40)
733 at clojure.lang.LazySeq.seq(LazySeq.java:49)
734 at clojure.lang.RT.seq(RT.java:521)
735 at clojure.core$seq__4357.invokeStatic(core.clj:137)
736 at clojure.core$filter$fn__4812.invoke(core.clj:2700)
737 at clojure.lang.LazySeq.sval(LazySeq.java:40)
738 at clojure.lang.LazySeq.seq(LazySeq.java:49)
739 at clojure.lang.RT.seq(RT.java:521)
740 at clojure.lang.LazilyPersistentVector.create(LazilyPersistentVector.java:44)
741 at clojure.core$vec.invokeStatic(core.clj:377)
742 at clojure.core$vec.invoke(core.clj:367)
743 at cljs.stacktrace$eval9220$fn__9221.invoke(stacktrace.cljc:138)
744 at clojure.lang.MultiFn.invoke(MultiFn.java:243)
745 at cljs.repl.browser.BrowserEnv._parse_stacktrace(browser.clj:281)
746 at cemerick.piggieback$fn__9491.invokeStatic(piggieback.clj:100)
747 at cemerick.piggieback$fn__9491.invoke(piggieback.clj:99)
748 at cljs.repl$eval8750$fn__8751$G__8741__8762.invoke(repl.cljc:147)
749 at cljs.repl$display_error$fn__8901.invoke(repl.cljc:440)
750 at cljs.repl$display_error.invokeStatic(repl.cljc:439)
751 at cljs.repl$display_error.invoke(repl.cljc:428)
752 at cljs.repl$repl_caught.invokeStatic(repl.cljc:753)
753 at cljs.repl$repl_caught.invoke(repl.cljc:744)
754 at cemerick.piggieback$run_cljs_repl$fn__9524.invoke(piggieback.clj:206)
755 at cljs.repl$repl_STAR_$fn__9046$fn__9055.invoke(repl.cljc:927)
756 at cljs.repl$repl_STAR_$fn__9046.invoke(repl.cljc:924)
757 at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1271)
758 at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1260)
759 at cljs.repl$repl_STAR_.invokeStatic(repl.cljc:888)
760 at cljs.repl$repl_STAR_.invoke(repl.cljc:760)
761 at cemerick.piggieback$run_cljs_repl.invokeStatic(piggieback.clj:169)
762 at cemerick.piggieback$run_cljs_repl.invoke(piggieback.clj:155)
763 at clojure.lang.AFn.applyToHelper(AFn.java:171)
764 at clojure.lang.AFn.applyTo(AFn.java:144)
765 at clojure.core$apply.invokeStatic(core.clj:650)
766 at clojure.core$apply.invoke(core.clj:641)
767 at cemerick.piggieback$evaluate.invokeStatic(piggieback.clj:259)
768 at cemerick.piggieback$evaluate.invoke(piggieback.clj:255)
769 at clojure.lang.Var.invoke(Var.java:379)
770 at cemerick.piggieback$wrap_cljs_repl$fn__9548$fn__9550$fn__9551.invoke(piggieback.clj:291)
771 at cemerick.piggieback$enqueue$fn__9534.invoke(piggieback.clj:247)
772 at clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__994.invoke(interruptible_eval.clj:190)
773 at clojure.lang.AFn.run(AFn.java:22)
774 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
775 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
776 at java.lang.Thread.run(Thread.java:748)
777
778Error: goog.require could not find: cljsjs.d3
779 at Object.goog.require [as require__] (http://192.168.124.5:9000/goog/base.js:711:15)
780 at Object.clojure.browser.repl.bootstrap.goog.require (http://192.168.124.5:9000/clojure/browser/repl.js:295:16)
781 at eval (eval at <anonymous> (http://192.168.124.5:9000/clojure/browser/repl.js:106:297), <anonymous>:1:6)
782 at http://192.168.124.5:9000/clojure/browser/repl.js:106:297
783 at clojure$browser$repl$evaluate_javascript (http://192.168.124.5:9000/clojure/browser/repl.js:109:4)
784 at Object.callback (http://192.168.124.5:9000/clojure/browser/repl.js:316:169)
785 at goog.net.xpc.CrossPageChannel.goog.messaging.AbstractChannel.deliver (http://192.168.124.5:9000/goog/messaging/abstractchannel.js:141:13)
786 at goog.net.xpc.CrossPageChannel.xpcDeliver (http://192.168.124.5:9000/goog/net/xpc/crosspagechannel.js:734:12)
787 at Function.goog.net.xpc.NativeMessagingTransport.messageReceived_ (http://192.168.124.5:9000/goog/net/xpc/nativemessagingtransport.js:321:13)
788 at Object.goog.events.fireListener (http://192.168.124.5:9000/goog/events/events.js:744:21)
789cljs.user> (require 'cljsjs.d3)
===========================================
1. Unhandled clojure.lang.ExceptionInfo
6 Error: goog.require could not find: cljsjs.d3
7 {:type :js-eval-exception,
8 :error
9 {:status :exception,
10 :ua-product :chrome,
11 :value "Error: goog.require could not find: cljsjs.d3",
12 :stacktrace
13 "Error: goog.require could not find: cljsjs.d3\n at Object.goog.require [as require__] (http://192.168.124.5:9000/goog/base.js:711:15)\n at Object.clojure.browser.repl.bootstrap.$
14 :form (require 'cljsjs.d3),
15 :js "goog.require('cljsjs.d3');\nnull;\n"}
16
17 core.clj: 4617 clojure.core/ex-info
18 repl.cljc: 527 cljs.repl$evaluate_form/invokeStatic
20 repl.cljc: 452 cljs.repl$evaluate_form/invoke
21 repl.cljc: 625 cljs.repl$eval_cljs/invokeStatic
22 repl.cljc: 618 cljs.repl$eval_cljs/invoke
23 repl.cljc: 880 cljs.repl$repl_STAR_$read_eval_print__9038/invoke
24 repl.cljc: 925 cljs.repl$repl_STAR_$fn__9046$fn__9055/invoke
25 repl.cljc: 924 cljs.repl$repl_STAR_$fn__9046/invoke
26 compiler.cljc: 1271 cljs.compiler$with_core_cljs/invokeStatic
27 compiler.cljc: 1260 cljs.compiler$with_core_cljs/invoke
28 repl.cljc: 888 cljs.repl$repl_STAR_/invokeStatic
29 repl.cljc: 760 cljs.repl$repl_STAR_/invoke
30 piggieback.clj: 169 cemerick.piggieback/run-cljs-repl
31 piggieback.clj: 155 cemerick.piggieback/run-cljs-repl
32 AFn.java: 171 clojure.lang.AFn/applyToHelper
33 AFn.java: 144 clojure.lang.AFn/applyTo
34 core.clj: 650 clojure.core/apply
35 core.clj: 641 clojure.core/apply
36 piggieback.clj: 259 cemerick.piggieback/evaluate
37 piggieback.clj: 255 cemerick.piggieback/evaluate
38 Var.java: 379 clojure.lang.Var/invoke
39 piggieback.clj: 291 cemerick.piggieback/wrap-cljs-repl/fn/fn/fn
40 piggieback.clj: 247 cemerick.piggieback/enqueue/fn
41 AFn.java: 22 clojure.lang.AFn/run
43 ThreadPoolExecutor.java: 1149 java.util.concurrent.ThreadPoolExecutor/runWorker
44 ThreadPoolExecutor.java: 624 java.util.concurrent.ThreadPoolExecutor$Worker/run
45 Thread.java: 748 java.lang.Thread/run
project.clj:
(defproject apps "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:repositories [#_["my.datomic.com" {:url "https://my.datomic.com/repo"
:snapshots false
:username "xfcjscn#gmail.com"
:password "18f81b06-0226-4d59-9060-7e01182a6030"}]]
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/core.async "0.3.443"]
[org.clojure/tools.logging "0.4.0"]
[org.clojure/tools.reader "1.1.0"]
[org.clojure/clojurescript "1.9.946"]
[org.clojure/math.numeric-tower "0.0.4"]
;; apps.nrepl-cider
[cider/cider-nrepl "0.15.1"]
;; seems weasel is optional, I can integrate cider with piggieback to support browser support. It's bad to introduce weasel api into my cljs file
[com.cemerick/piggieback "0.2.2"]
;; cms
[ring "1.6.3"]
[ring/ring-defaults "0.3.1"]
[ring-webjars "0.2.0" :exclusions [com.fasterxml.jackson.core/jackson-core]]
[compojure "1.6.0"]
[hiccup "1.0.5"]
;; my licence expire on 2017/05/17, upgrade not supported, so only 0.9.5561 supported. can register new account?
;; this is free but not for open source
;;[com.datomic/datomic-pro "0.9.5561" :exclusions [commons-codec org.apache.httpcomponents/httpclient org.slf4j/slf4j-nop]]
[com.datomic/datomic-free "0.9.5561.62" :exclusions [commons-codec org.apache.httpcomponents/httpclient org.slf4j/slf4j-nop com.google.guava/guava]]
[org.webjars.bower/tether "1.4.0"]
[org.webjars/bootstrap "4.0.0-beta.2"]
[org.webjars.bower/semantic "2.2.13"]
[endophile "0.2.1"]
[buddy/buddy-auth "2.1.0"]
[oauth-clj "0.1.15" :exclusions [commons-logging]]
[org.danielsz/system "0.4.0"]
[com.cemerick/pomegranate "1.0.0" :exclusions [commons-logging]]
[prone "1.1.4"]
[ring-logger "0.7.7"]
;; logging
[org.slf4j/jcl-over-slf4j "1.7.25"]
[ch.qos.logback/logback-classic "1.2.3"]
;; for tools
[enlive "1.1.6"]
[com.draines/postal "2.0.2"]
;; for incanter-example
[net.mikera/core.matrix "0.61.0"]
[incanter "1.9.0"]
;; for ml week 4
[net.mikera/imagez "0.12.0"]
[quil "2.6.0"]
;; mvn install:install-file -DgroupId=apps -DartifactId=extruder -Dversion=1.02 -Dpackaging=jar -Dfile=extruder.jar -DgeneratePom=true -DcreateChecksum=true
[apps/extruder "1.02"]
[apps/peasycam "202"]
[apps/shapes3d "2.2"]
;; func-plot
[prismatic/dommy "1.1.0"]
[hipo "0.5.2"]
[cljsjs/three "0.0.87-0"]
;; sources
[org.processing/core "3.3.6" :classifier "sources"]
]
;;:jvm-opts ["-Xmx6g" "-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"]
;; cider don't inject this automaticlly, so duplicate with code in nrepl-cider
:repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
:plugins [[lein-ancient "0.6.14"]]
)
REPL startup script:
(ns apps.cljs-rt-browser
(:require [clojure.tools.logging :as log]
[clojure.java.io :as io]
[hiccup.core :refer [html]]
[hiccup.page :refer [include-js]]
[hiccup.element :refer [javascript-tag]]
cljs.build.api
cljs.repl.browser
cemerick.piggieback
))
(def repl-client-url "http://192.168.124.5:9000/repl")
(def index-hcp
[:html
[:head]
[:body
(include-js "goog/base.js" "main.js")
(javascript-tag (cljs.build.api/compile {} '(require 'clojure.browser.repl)))
(javascript-tag (cljs.build.api/compile {} (apply list `(clojure.browser.repl/connect ~repl-client-url))))]])
(def index-path "out/index.html")
(defn -main []
;; generate:
;; module system: goog/base.js, module info of google: goog/deps.js, module of google: goog/**
;; module info of other: main.js, module of others
(cljs.build.api/build "src" {:output-to "out/main.js"
:browser-repl true
:verbose true
})
;; repl will serve static, so just generate index.html
(when-not (. (io/file index-path) exists)
(spit index-path (html index-hcp)))
;; exclude "." from static-dir to avoid overwrite of repl compiled files: out/out/**
(cemerick.piggieback/cljs-repl (cljs.repl.browser/repl-env :static-dir ["out/"]) :repl-verbose true))
(-main)

Cannot connect to compose.io hosted rethinkdb with clojure

I'm using the clojure rethinkdb library https://github.com/apa512/clj-rethinkdb - here's my connection snippet:
(ns rethink.core
(:require
[environ.core]
[cheshire.core :as json]
[org.httpkit.client :as http]
[rethinkdb.query :as r]))
(defn rethink-connect
[]
(r/connect :host (environ.core/env :rethinkdb-host)
:port (environ.core/env :rethinkdb-port)
:db (environ.core/env :rethinkdb-db)
:auth-key (environ.core/env :rethinkdb-auth)))
(defn record-event!
[event collection]
(let [r (with-open [conn (rethink-connect)]
(-> (r/table collection)
(r/insert [event])
(r/run conn)))]))
But I keep getting the error:
clojure.lang.ExceptionInfo: Error connecting to RethinkDB database
core.clj:4617 clojure.core/ex-info
core.clj:4617 clojure.core/ex-info
core.clj:88 rethinkdb.core/connect
core.clj:43 rethinkdb.core/connect
RestFn.java:619 clojure.lang.RestFn.invoke
core.clj:10 rethink.core/rethink-connect
core.clj:8 rethink.core/rethink-connect
core.clj:17 rethink.core/record-event!
core.clj:15 rethink.core/record-event!
core.clj:23 webhook.core/record-event!
core.clj:21 webhook.core/record-event!
handler.clj:11 webhook.handler/webhook-post
handler.clj:8 webhook.handler/webhook-post
handler.clj:9 app.handler/fn
handler.clj:9 app.handler/fn
core.clj:135 compojure.core/make-route[fn]
core.clj:122 compojure.core/wrap-route-middleware[fn]
core.clj:126 compojure.core/wrap-route-info[fn]
core.clj:45 compojure.core/if-route[fn]
core.clj:27 compojure.core/if-method[fn]
core.clj:151 compojure.core/routing[fn]
core.clj:2592 clojure.core/some
core.clj:2583 clojure.core/some
core.clj:151 compojure.core/routing
core.clj:148 compojure.core/routing
RestFn.java:139 clojure.lang.RestFn.applyTo
core.clj:648 clojure.core/apply
core.clj:641 clojure.core/apply
core.clj:156 compojure.core/routes[fn]
keyword_params.clj:35 ring.middleware.keyword-params/wrap-keyword-params[fn]
params.clj:64 ring.middleware.params/wrap-params[fn]
absolute_redirects.clj:38 ring.middleware.absolute-redirects/wrap-absolute-redirects[fn]
content_type.clj:30 ring.middleware.content-type/wrap-content-type[fn]
default_charset.clj:26 ring.middleware.default-charset/wrap-default-charset[fn]
not_modified.clj:52 ring.middleware.not-modified/wrap-not-modified[fn]
Var.java:379 clojure.lang.Var.invoke
reload.clj:22 ring.middleware.reload/wrap-reload[fn]
stacktrace.clj:23 ring.middleware.stacktrace/wrap-stacktrace-log[fn]
stacktrace.clj:86 ring.middleware.stacktrace/wrap-stacktrace-web[fn]
jetty.clj:20 ring.adapter.jetty/proxy-handler[fn]
(Unknown Source) ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle
HandlerWrapper.java:116 org.eclipse.jetty.server.handler.HandlerWrapper.handle
Server.java:369 org.eclipse.jetty.server.Server.handle
AbstractHttpConnection.java:486 org.eclipse.jetty.server.AbstractHttpConnection.handleRequest
AbstractHttpConnection.java:944 org.eclipse.jetty.server.AbstractHttpConnection.content
AbstractHttpConnection.java:1005 org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content
HttpParser.java:865 org.eclipse.jetty.http.HttpParser.parseNext
HttpParser.java:240 org.eclipse.jetty.http.HttpParser.parseAvailable
AsyncHttpConnection.java:82 org.eclipse.jetty.server.AsyncHttpConnection.handle
SelectChannelEndPoint.java:668 org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle
SelectChannelEndPoint.java:52 org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run
QueuedThreadPool.java:608 org.eclipse.jetty.util.thread.QueuedThreadPool.runJob
QueuedThreadPool.java:543 org.eclipse.jetty.util.thread.QueuedThreadPool$3.run
Thread.java:745 java.lang.Thread.run
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character
RT.java:1177 clojure.lang.RT.intCast
tcp.clj:156 aleph.tcp/client
tcp.clj:126 aleph.tcp/client
core.clj:61 rethinkdb.core/connect
I'm getting the host "aws-us-xxx-1-portal.xxx.xxxx.com", port "15731", db "dev" and auth-key from my compose.io rethinkdb instance. The auth-key is the admin password taken from authentication credential provided by compose.io interface. Not sure what's going on.
Actually, I needed to use a :ca-cert parameter as well, with the certificate being provided from the compose.io web interface.

:use fails in lein project

When I try to use
(ns eight-puzzle.core
(:use [clojure.contrib.seq :only (positions)]))
I get this error
java.io.FileNotFoundException: Could not locate clojure/contrib/seq__init.class or clojure/contrib/seq.clj on classpath:
RT.java:443 clojure.lang.RT.load
RT.java:411 clojure.lang.RT.load
core.clj:5530 clojure.core/load[fn]
core.clj:5529 clojure.core/load
RestFn.java:408 clojure.lang.RestFn.invoke
core.clj:5336 clojure.core/load-one
core.clj:5375 clojure.core/load-lib[fn]
core.clj:5374 clojure.core/load-lib
RestFn.java:142 clojure.lang.RestFn.applyTo
core.clj:619 clojure.core/apply
core.clj:5413 clojure.core/load-libs
RestFn.java:137 clojure.lang.RestFn.applyTo
core.clj:621 clojure.core/apply
core.clj:5507 clojure.core/use
RestFn.java:408 clojure.lang.RestFn.invoke
NO_SOURCE_FILE:1 eight-puzzle.core/eval8699[fn]
NO_SOURCE_FILE:1 eight-puzzle.core/eval8699
And this problem happens when ever I try to import anything in. Did I do something wrong when setting up clojure?
External dependencies, for projects managed by Leiningen, should be specified in the project.clj file, under the :dependencies key.
(defproject project1 "0.0.1"
:description "Something"
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/clojure-contrib "1.2.0"]
[clj-time "0.6.0"]])
Note: The entries in :dependencies can originate from either maven (maven central repository) or Clojars.
It also looks like you are using clojure.contrib. This library has been deprecated and you should upgrade, if you can. If you are only using clojure.contrib.seq/positions, take a look at this StackOverflow answer. You can also reimplement it with just clojure.core functions:
(defn positions [pred coll]
(for [[idx elt]
(map-indexed vector coll)
:when (pred elt)]
idx))

How do I eval a clojure data structure within the context of a namespace?

I'm writing a clojure app for internal use, and I want the config file to be in clojure too. I have defined a few macros to make writing the config file easier, but when I try to eval the data from the config file, it cant find my macros. This works fine from the REPL however. For example, I'm using
(load-string "/path/to/config")
I get this error:
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: defcmd in this context, compiling:(null:1)
at clojure.lang.Compiler.analyze(Compiler.java:6235)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3452)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6411)
at clojure.lang.Compiler.analyze(Compiler.java:6216)
at clojure.lang.Compiler.analyze(Compiler.java:6177)
at clojure.lang.Compiler.eval(Compiler.java:6469)
at clojure.lang.Compiler.load(Compiler.java:6902)
at clojure.lang.Compiler.load(Compiler.java:6872)
at clojure.core$load_reader.invoke(core.clj:3625)
at clojure.core$load_string.invoke(core.clj:3635)
at serverStats.core$load_config.invoke(core.clj:67)
at serverStats.core$_main.doInvoke(core.clj:78)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.Var.invoke(Var.java:397)
at user$eval109.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6455)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$null_opt.invoke(main.clj:348)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:405)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Unable to resolve symbol: defcmd in this context
at clojure.lang.Util.runtimeException(Util.java:156)
at clojure.lang.Compiler.resolveIn(Compiler.java:6720)
at clojure.lang.Compiler.resolve(Compiler.java:6664)
at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6625)
at clojure.lang.Compiler.analyze(Compiler.java:6198)
... 28 more
However, running that same command from the REPL in my namespace works fine.
You probably want some more sophisticated loading scheme. I assume you want to put the configuration into a dedicated configuration namespace. It will only contain the configuration. Helper functions are held in a separate namespace use'd in the configuration namespace.
(defn setup-config-space
[]
(binding [*ns* *ns*]
(in-ns 'config.namespace)
(refer-clojure)
(use 'config.helpers)))
(defn load-config
[path]
(binding [*ns* *ns*]
(in-ns 'config.namespace)
(load-file path)))
See the example use:
..ojure/1.4.0-alpha3% cat config/helpers.clj
(ns config.helpers)
(defmacro defcmd
[x]
`(defn ~x [] "Hello"))
..ojure/1.4.0-alpha3% cat x.clj
(defcmd foo)
..ojure/1.4.0-alpha3% java -cp .:clojure-1.4.0-alpha3.jar clojure.main -r
Clojure 1.4.0-alpha3
user=> ; Paste above functions
#'user/setup-config-space
#'user/load-config
user=> (setup-config-space)
nil
user=> (load-config "x.clj")
#'config.namespace/foo
user=> (config.namespace/foo)
"Hello"