Could not locate clojure/tools/logging__init.class - clojure

Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/tools/logging__init.class or clojure/tools/logging.clj on classpath
Getting this error every time I run the project using.
There is a stack trace but it doesn't show whether the error is coming from my code or not ?
at clojure.lang.RT.load(RT.java:443)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
at clojure.core$load_lib.doInvoke(core.clj:5374)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$load_libs.doInvoke(core.clj:5413)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$require.doInvoke(core.clj:5496)
at clojure.lang.RestFn.invoke(RestFn.java:551)
at tombooth.friend_token$eval3554$loading__4910__auto____3555.invoke(friend_token.clj:1)
at tombooth.friend_token$eval3554.invoke(friend_token.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6608)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.RT.loadResourceScript(RT.java:370)
at clojure.lang.RT.loadResourceScript(RT.java:361)
at clojure.lang.RT.load(RT.java:440)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
at clojure.core$load_lib.doInvoke(core.clj:5374)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$load_libs.doInvoke(core.clj:5413)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$require.doInvoke(core.clj:5496)
at clojure.lang.RestFn.invoke(RestFn.java:512)
at auth_friend.handler$eval1857$loading__4910__auto____1858.invoke(handler.clj:1)
at auth_friend.handler$eval1857.invoke(handler.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6608)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.RT.loadResourceScript(RT.java:370)
at clojure.lang.RT.loadResourceScript(RT.java:361)
at clojure.lang.RT.load(RT.java:440)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
at clojure.core$load_lib.doInvoke(core.clj:5374)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$load_libs.doInvoke(core.clj:5413)
I was running the basic sample for this friend-redis-token project
Also I am running Leiningen 2.3.3 on Java 1.7.0_45 Java HotSpot(TM) 64-Bit Server VM
EDIT: Here is the project.clj
(defproject auth_friend "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.5.1"]
[compojure "1.1.6"]
[com.cemerick/friend "0.2.0"]]
:plugins [[lein-ring "0.8.8"]]
:ring {:handler auth_friend.handler/app}
:profiles
{:dev {:dependencies [[javax.servlet/servlet-api "2.5"]
[ring-mock "0.1.5"]]}})
initially I tried by mentioning the clojar as a dependency as given in the github page of the project and then later on I downloaded both the repositories and made them part of my project.
keeping the namespace same.
but still its giving exactly the same issue.
.
├── #auth_fri#
├── README.md
├── project.clj
├── resources
│   └── public
├── src
│   ├── auth_friend
│   │   ├── #handler.clj#
│   │   └── handler.clj
│   └── tombooth
│   ├── friend_token
│   │   ├── redis.clj
│   │   ├── token.clj
│   │   └── token_store.clj
│   └── friend_token.clj
├── target
│   ├── classes
│   └── stale
│   └── extract-native.dependencies
└── test
└── auth_friend
└── test
└── handler.clj

If you're using logging you need the dependency:
[org.clojure/tools.logging "0.2.6"]
In your project, which is missing from the dependency vector on your project file.

Related

FileNotFoundException when requiring namespaces in Clojure

I want to use clojure.java.io and clojure.data.csv in my app.
This is how I've required those namespaces:
(ns my-app.core
(:gen-class)
(:require [clojure.java.io :as io]
[clojure.data.csv :as csv]))
When I evaluate that ns function in the REPL, I get this error:
; Execution error (FileNotFoundException) at my-app.core/eval8295$loading (form-init1647489175359256060.clj:1).
; Could not locate clojure/data/csv__init.class, clojure/data/csv.clj or clojure/data/csv.cljc on classpath.
VS Code v1.62.3 / Calva. v2.0.229 / Leiningen v2.9.8 on Java v15.0.1 / macOS v11.6.1
This is my Java class path, as produced with within the same REPL session by calling (java.lang.System/getProperty "java.class.path"):
"/Users/my-username/Code/my-app/test:/Users/my-username/Code/my-app/src:/Users/my-username/Code/my-app/dev-resources:/Users/my-username/Code/my-app/resources:/Users/my-username/Code/my-app/target/default/classes:/Users/my-username/.m2/repository/cider/cider-nrepl/0.22.4/cider-nrepl-0.22.4.jar:/Users/my-username/.m2/repository/nrepl/nrepl/0.8.3/nrepl-0.8.3.jar:/Users/my-username/.m2/repository/org/clojure/clojure/1.10.3/clojure-1.10.3.jar:/Users/my-username/.m2/repository/org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar:/Users/my-username/.m2/repository/org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar:/Users/my-username/.m2/repository/org/nrepl/incomplete/0.1.0/incomplete-0.1.0.jar"
And this is my app directory structure (scaffolded with lein new app my-app):
.
├── CHANGELOG.md
├── LICENSE
├── README.md
├── doc
│   └── intro.md
├── project.clj
├── resources
│   ├── my-data-1.csv
│   └── my-data-2.csv
├── src
│   └── my_app
│   └── core.clj
├── target
│   └── default
│   ├── classes
│   │   └── META-INF
│   │   └── maven
│   │   └── my-app
│   │   └── my-app
│   │   └── pom.properties
│   ├── repl-port
│   └── stale
│   └── leiningen.core.classpath.extract-native-dependencies
└── test
└── my_app
└── core_test.clj
It looks like something is wrong with my Java environment, or perhaps my Clojure installation. I can't seem to figure out where the problem lies, and how to go about fixing it.
Any advice would be greatly appreciated.
I had neglected to add clojure.data.csv to my project.clj file.
Here is the project.clj with the changes applied to :dependencies:
(defproject my-app "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.3"]
[org.clojure/data.csv "1.0.0"]]
:main ^:skip-aot my-app.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}})
Relevant part:
:dependencies [[org.clojure/clojure "1.10.3"]
[org.clojure/data.csv "1.0.0"]]
Now it works fine.

Unison: Ignore files with Regex doesn't work

I tried to ignore some files that end with ".NUMBERS" like .133443. I tried this Regex but it still copies the files:
unison -batch -owner -group -times -ignore "Regex ^*\.[0-9]+$" /hadoop/bigdata/giin/data ssh://cnp31ginhortonen1.giin.recouv//hadoop/bigdata/giin/data -prefer newer`
Source :
[root#cnp31ginhortonen1 .unison]# tree /hadoop/bigdata/giin/data/
/hadoop/bigdata/giin/data/
├── aefd.csv
├── aefd.log
├── aefd.xml
├── subdir
│   ├── aefd.csv
│   ├── aefd.log
│   ├── aefd.xml
│   └── TB5E.B01.117.210409074
├── TB5E.B01.117.10409074
└── TB5E.B01.117.210409074

Classpath conflict: org.clojure/clojure version 1.7.0 already loaded, NOT loading version 1.8.0

When copying a build.boot file from an old project to a new one I got the following error and found nothing on Google:
Classpath conflict: org.clojure/clojure version 1.7.0 already loaded, NOT loading version 1.8.0
You should just include [org.clojure/clojure "1.8.0"] with the same version as boot environment variable BOOT_CLOJURE_VERSION=1.8.0
into build.boot dependencies list.
Another way to get rid of this issues is to exclude clojure dependency from several dependencies in the list.
boot show -d
Will show your list of dependencies,
Classpath conflict: org.clojure/clojure version 1.8.0 already loaded, NOT loading version 1.7.0
2018-01-16 15:05:21.023:INFO::main: Logging initialized #6899ms
[adzerk/boot-cljs "2.1.4" :scope "test"]
[adzerk/boot-reload "0.5.2" :scope "test"]
[hiccup "1.0.5"]
[org.clojure/clojurescript "1.9.946"]
├── [com.google.javascript/closure-compiler-unshaded "v20170910"]
│ ├── [args4j "2.33"]
│ ├── [com.google.code.findbugs/jsr305 "3.0.1"]
│ ├── [com.google.code.gson/gson "2.7"]
│ ├── [com.google.errorprone/error_prone_annotations "2.0.18"]
│ ├── [com.google.guava/guava "20.0"]
│ ├── [com.google.javascript/closure-compiler-externs "v20170910"]
│ ├── [com.google.jsinterop/jsinterop-annotations "1.0.0"]
│ └── [com.google.protobuf/protobuf-java "3.0.2"]
├── [org.clojure/google-closure-library "0.0-20170809-b9c14c6b"]
│ └── [org.clojure/google-closure-library-third-party "0.0-20170809-b9c14c6b"]
├── [org.clojure/tools.reader "1.1.0"]
└── [org.mozilla/rhino "1.7R5"]
[org.clojure/data.json "0.2.6"]
[pandeiro/boot-http "0.8.3"]
└── [org.clojure/clojure "1.7.0"]
[ring/ring-core "1.6.3" :exclusions [[org.clojure/clojure]]]
├── [clj-time "0.11.0"]
│ └── [joda-time "2.8.2"]
├── [commons-fileupload "1.3.3"]
├── [commons-io "2.5"]
├── [crypto-equality "1.0.0"]
├── [crypto-random "1.2.0"]
└── [ring/ring-codec "1.0.1"]
└── [commons-codec "1.6"]
[ring/ring-jetty-adapter "1.6.3" :exclusions [[org.clojure/clojure]]]
├── [org.eclipse.jetty/jetty-server "9.2.21.v20170120"]
│ ├── [javax.servlet/javax.servlet-api "3.1.0"]
│ ├── [org.eclipse.jetty/jetty-http "9.2.21.v20170120"]
│ │ └── [org.eclipse.jetty/jetty-util "9.2.21.v20170120"]
│ └── [org.eclipse.jetty/jetty-io "9.2.21.v20170120"]
└── [ring/ring-servlet "1.6.3"]
As you can see here is:
[pandeiro/boot-http "0.8.3"]
└─[org.clojure/clojure "1.7.0"]
dependency, which boot is complaining on. So, what I did to get rid of this dependency is to make exclusion in build.boot like here:
[pandeiro/boot-http "0.8.3" :exclusions [org.clojure/clojure]]
so pandeiro/boot-http does not depend on old clojure version anymore and boot compain dissapeared.
Well the answer is pretty simple. I was missing the boot.properties file in the root folder. Just create a file with the following content:
#https://github.com/boot-clj/boot
#Sun Nov 01 16:34:27 CET 2015
BOOT_CLOJURE_NAME=org.clojure/clojure
BOOT_VERSION=2.7.1
BOOT_CLOJURE_VERSION=1.8.0

lein midje coudn't locate some file

I'm trying to do unit-testing using midje, and I hit some wall.
Assuming I have this directory structure:
├── src
│   └── clj
│   └── faris
│   └── lune
│   ├── core.clj
│   ├── index
│   │   ├── comment.clj
│   │   └── place.clj
│   ├── middleware
│      └── core.clj
└── test
└── clj
└── faris
└── lune
└── middleware
└── t_core.clj
which .../faris/lune/middleware/t_core.clj contains a simple test:
(ns faris.lune.middleware.t-core
(:require [faris.lune.middleware.core :refer :all]
[midje.sweet :refer :all]))
(fact "simple test"
(+ 1 1) => 2)
It always fail with the following error message:
Exception in thread "main" java.io.FileNotFoundException: Could not locate faris/lune/middleware/t_core__init.class or faris/lune/middleware/t_core.clj on classpath: , compiling:(/tmp/form-init2527989536148890974.clj:1:90)
at clojure.lang.Compiler.load(Compiler.java:7142)
at clojure.lang.Compiler.loadFile(Compiler.java:7086)
at clojure.main$load_script.invoke(main.clj:274)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invoke(main.clj:307)
at clojure.main$null_opt.invoke(main.clj:342)
at clojure.main$main.doInvoke(main.clj:420)
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.io.FileNotFoundException: Could not locate faris/lune/middleware/t_core__init.class or faris/lune/middleware/t_core.clj on classpath:
at clojure.lang.RT.load(RT.java:443)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5066.invoke(core.clj:5641)
at clojure.core$load.doInvoke(core.clj:5640)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5446)
at clojure.core$load_lib$fn__5015.invoke(core.clj:5486)
at clojure.core$load_lib.doInvoke(core.clj:5485)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:626)
at clojure.core$load_libs.doInvoke(core.clj:5524)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:626)
at clojure.core$require.doInvoke(core.clj:5607)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at midje.repl$load_facts$fn__7983.invoke(repl.clj:206)
at midje.repl$load_facts.doInvoke(repl.clj:192)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at user$eval8046.invoke(form-init2527989536148890974.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6693)
at clojure.lang.Compiler.load(Compiler.java:7130)
... 11 more
Subprocess failed
Which is very cryptic to me, since it was like midje found the the test file, read the ns (faris.lune.middleware.t-core) and then saying it can't find it.
Any help? I must be missing something obvious.

Connecting to ClojureScript bREPL: clojure.browser.repl/connect throws TypeError in compiled JavaScript

I'm trying to connect to a ClojureScript browser REPL, and I'm having trouble with clojure.browser.repl/connect. My compiled JavaScript throws a TypeError trying to call appendChild on a null object in the block of Google Closure code at the top. I'm following the instructions in ClojureScript: Up and Running (Chapter 9, p.78, available in the preview), and wondering if the tooling for this has changed since it was published.
I'm using Leiningen 2.0.0, Java 1.6.0_37, OS X 10.7.5, plus the dependencies in my project.clj:
(defproject brepl-hello "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.4.0"]
[org.clojure/clojurescript "0.0-1552"]
[compojure "1.1.5"]
[ring/ring-jetty-adapter "1.1.8"]]
:plugins [[lein-cljsbuild "0.3.0"]]
:source-paths ["src/clj"]
:cljsbuild {:builds [{
:source-paths ["src/cljs"]
:compiler {
:output-to "resources/public/brepl-hello.js"
:optimizations :whitespace
:pretty-print true}}]})
Here's the only ClojureScript source file, src/cljs/brepl_hello/brepl-hello.cljs:
(ns brepl-hello
(:require [clojure.browser.repl :as repl]))
(repl/connect "http://localhost:9000/repl")
This compiles to the file resources/public/brepl-hello.js, which I've inserted into index.html in the same directory:
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="brepl-hello.js"></script>
</head>
<body>
</body>
</html>
I've been serving this on port 3000 with Ring/Jetty from the REPL or Python SimpleHTTPServer. When I open this page in Chrome, the dev console shows Uncaught TypeError: Cannot call method 'appendChild' of null, with a traceback to this if/else block in the Google Closure code at the top of the complied js file, where parentElm (passed in to the containing function as a parameter) is null.
if(goog.userAgent.GECKO || goog.userAgent.WEBKIT) {
window.setTimeout(goog.bind(function() {
parentElm.appendChild(iframeElm);
iframeElm.src = peerUri.toString();
goog.net.xpc.logger.info("peer iframe created (" + iframeId + ")")
}, this), 1)
}else {
iframeElm.src = peerUri.toString();
parentElm.appendChild(iframeElm);
goog.net.xpc.logger.info("peer iframe created (" + iframeId + ")")
}
This seems to be a problem with clojure.browser.repl/connect. Swapping out this line in the ClojureScript source for something like:
(ns brepl-hello
(:require [clojure.browser.repl :as repl]))
(.write js/document "Hello World!")
Will compile and run in the browser just fine. I suspect something is misconfigured in my build settings or directory structure, or I'm making a noob mistake somewhere in all this. What's changed since the time the instructions I'm following were published? I found a couple references to this problem in the #clojure irc logs, but no solution.
Finally, here's an abbreviated directory tree for reference:
├── out
│   ├── cljs
│   │   ├── core.cljs
│   │   └── core.js
│   ├── clojure
│   │   └── browser
│   │   ├── event.cljs
│   │   ├── event.js
│   │   ├── net.cljs
│   │   ├── net.js
│   │   ├── repl.cljs
│   │   └── repl.js
│   └── goog
│   └── [...]
├── pom.xml
├── project.clj
├── resources
│   └── public
│   ├── brepl-hello.js
│   └── index.html
├── src
│   ├── clj
│   │   └── brepl_hello
│   │   └── core.clj
│   └── cljs
│   └── brepl_hello
│   └── brepl-hello.cljs
└─── target
   ├── brepl-hello-0.1.0-SNAPSHOT.jar
   ├── classes
   ├── cljsbuild-compiler-0
   │   ├── brepl_hello
   │   │   └── brepl-hello.js
    │   ├── cljs
   │   │   ├── core.cljs
   │   │   └── core.js
    │   └── clojure
   │   └── browser
   │   ├── event.cljs
   │   ├── event.js
   │   ├── net.cljs
   │   ├── net.js
    │   ├── repl.cljs
    │   └── repl.js
   └── stale
   └── extract-native.dependencies
Well, its open source and looking at the code it seems that document.body is null at the time the repl hidden iframe is being added to it (the connect call leads to this point).
You should do this connect call on dom ready or body on load and it should work fine.
Take a look at:
https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-02.md
or, for a better brepl experience, here
https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-18.md