How to troubleshoot FileNotFoundException: Could not locate clojure/tools/namespace/parse...?

1,087 views
Skip to first unread message

Jakub Holy

unread,
Apr 2, 2014, 7:49:07 AM4/2/14
to clo...@googlegroups.com
When starting lein (namely lein ring server) I got a little helpful exception and stack trace with the key line being:

FileNotFoundException: Could not locate clojure/tools/namespace/parse__init.class or clojure/tools/namespace/parse.clj on classpath

I have narrowed it down to the dependency [clj-ns-browser "1.3.1"] in myprofile.clj.

The problem is that the stack trace contains no indication that it is clj-ns-browser that is causing the problem. I would like to know if there are any tricks to troubleshoot these problems other than binary search through deps/plugins in profile.clj.

Thank you!

Here is the full stack trace:

$ lein ring server
Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/tools/namespace/parse__init.class or clojure/tools/namespace/parse.clj on classpath: , compiling:(ns_tracker/parse.clj:1:1)
at clojure.lang.Compiler.load(Compiler.java:7142)
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__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:628)
at clojure.core$use.doInvoke(core.clj:5618)
at clojure.lang.RestFn.invoke(RestFn.java:512)
at ns_tracker.core$eval514$loading__4958__auto____515.invoke(core.clj:1)
at ns_tracker.core$eval514.invoke(core.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6692)
at clojure.lang.Compiler.load(Compiler.java:7130)
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__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:628)
at clojure.core$use.doInvoke(core.clj:5618)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at ring.middleware.reload$eval508$loading__4958__auto____509.invoke(reload.clj:1)
at ring.middleware.reload$eval508.invoke(reload.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6692)
at clojure.lang.Compiler.load(Compiler.java:7130)
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__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:628)
at clojure.core$use.doInvoke(core.clj:5618)
at clojure.lang.RestFn.invoke(RestFn.java:512)
at ring.server.standalone$eval15$loading__4958__auto____16.invoke(standalone.clj:1)
at ring.server.standalone$eval15.invoke(standalone.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6692)
at clojure.lang.Compiler.load(Compiler.java:7130)
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__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:408)
at ring.server.leiningen$eval9$loading__4958__auto____10.invoke(leiningen.clj:1)
at ring.server.leiningen$eval9.invoke(leiningen.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6692)
at clojure.lang.Compiler.load(Compiler.java:7130)
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__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 user$eval5.invoke(form-init6357505187919130689.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6692)
at clojure.lang.Compiler.load(Compiler.java:7130)
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 clojure/tools/namespace/parse__init.class or clojure/tools/namespace/parse.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:628)
at clojure.core$use.doInvoke(core.clj:5618)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at ns_tracker.parse$eval575$loading__4958__auto____576.invoke(parse.clj:1)
at ns_tracker.parse$eval575.invoke(parse.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6703)
at clojure.lang.Compiler.eval(Compiler.java:6692)
at clojure.lang.Compiler.load(Compiler.java:7130)
... 120 more

Phillip Lord

unread,
Apr 2, 2014, 12:15:57 PM4/2/14
to clo...@googlegroups.com

I've just written a docstring which looks like this.

"Return true if superproperty is a superproperty of property."

This is a bit messy. More verbosely I could say:

"Return true if the formal parameter superproperty is a superproject of
the formal parameter property."


The other time issue I find problematic is when I refer to a function in
a docstring. So

"See declare-classes where frames (or just default frames) are not
needed."

which means "see the function declare-classes where frames..."

When I am writing emacs lisp, both of these have conventions. So

"Return true if SUPERPROPERTY is a superproperty of PROPERTY."
"See `declare-classes' where frames..."

Has anyone written up any documentation conventions of this sort for
Clojure yet? Does anyone else think they would be useful?

Phil

Sean Corfield

unread,
Apr 2, 2014, 6:01:15 PM4/2/14
to clo...@googlegroups.com
On Apr 2, 2014, at 4:49 AM, Jakub Holy <jakub...@iterate.no> wrote:
The problem is that the stack trace contains no indication that it is clj-ns-browser that is causing the problem. I would like to know if there are any tricks to troubleshoot these problems other than binary search through deps/plugins in profile.clj.

Well you can use: lein deps :tree

That will show you any version conflicts as well as the paths by which those conflicts are reached - and it will suggest exclusions to resolve the conflicts (although some version conflicts can't be resolved as-is - you must upgrade one or other of your dependencies to get things working).

But if you want to start from the stack trace...

A lot of the stack trace can be thrown away / ignored which helps narrow things down...

$ lein ring server
Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/tools/namespace/parse__init.class or clojure/tools/namespace/parse.clj on classpath: , compiling:(ns_tracker/parse.clj:1:1)

^^^ This tells us it failed to load clojure.tools.namespace.parse while compiling ns-tracker.parse...

at ns_tracker.core$eval514$loading__4958__auto____515.invoke(core.clj:1)
at ns_tracker.core$eval514.invoke(core.clj:1)

^^^ ...which it found in ns-tracker.core...

at ring.middleware.reload$eval508$loading__4958__auto____509.invoke(reload.clj:1)
at ring.middleware.reload$eval508.invoke(reload.clj:1)

^^^ ...which it found in ring.middleware.reload...


at ring.server.standalone$eval15$loading__4958__auto____16.invoke(standalone.clj:1)
at ring.server.standalone$eval15.invoke(standalone.clj:1)

^^^ ...which it found in ring.server.standalone...

at ring.server.leiningen$eval9$loading__4958__auto____10.invoke(leiningen.clj:1)
at ring.server.leiningen$eval9.invoke(leiningen.clj:1)

^^^ ...and now we're at the top-level (since this was invoked from the user namespace):

at user$eval5.invoke(form-init6357505187919130689.clj:1)

And because all these seem to be at line 1, they're likely the (ns ...) forms and so we have part of the dependency chain. I mostly just skipped over all the clojure.* stuff except for noting (in my head) that clojure.core/load and clojure.core/use were called along that path.

Does that help at all?

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)



signature.asc

Jakub Holy

unread,
Apr 3, 2014, 7:30:19 AM4/3/14
to clo...@googlegroups.com
Hello Sean, 

Thank you for your asnwer! It was a nice and helpful demonstration of how to read stack traces better.

The stack trace points to ns-tracker  as the cause and indeed removing it fixes the problem. However it is actually conflict between ns-tracker and clj-ns-browser that causes the failure; removing any one fixes it. But the stack trace points only to ns-tracker (I guess we actually cannot expect more from it.) Thank you for reminding me of lein deps :tree, I should finally remember to use it. It unfortunately does not mention clj-ns-browser at all (I have it among user dependencies in profile.clj). Any idea why could that be?

Thank you! 
--
Forget software. Strive to make an impact, deliver a valuable change.

(
Vær så snill og hjelp meg med å forbedre norsken min – skriftlig og muntlig. Takk!)

Jakub Holy
Solutions Engineer | +47 966 23 666
Iterate AS | www.iterate.no
The Lean Software Development Consultancy
- http://theholyjava.wordpress.com/ -

Sean Corfield

unread,
Apr 3, 2014, 3:10:30 PM4/3/14
to clo...@googlegroups.com
On Apr 3, 2014, at 4:30 AM, Jakub Holy <jakub...@iterate.no> wrote:
The stack trace points to ns-tracker  as the cause and indeed removing it fixes the problem. However it is actually conflict between ns-tracker and clj-ns-browser that causes the failure; removing any one fixes it. But the stack trace points only to ns-tracker (I guess we actually cannot expect more from it.) Thank you for reminding me of lein deps :tree, I should finally remember to use it. It unfortunately does not mention clj-ns-browser at all (I have it among user dependencies in profile.clj). Any idea why could that be?

I believe the answer is that clj-ns-browser is a tool that you run separately on your code, rather than something that runs as part of your code - so there's no execution path in your code that crosses into clj-ns-browser. However, Leiningen will merge in your :user dependencies from profiles.clj - which is why you get the conflict.

You might solve this by putting clj-ns-browser in a separate profile, say, :browse and then explicitly using that profile when you want to fire up clj-ns-browser (via lein's with-profile feature).
signature.asc

Stuart Sierra

unread,
Apr 3, 2014, 5:34:23 PM4/3/14
to clo...@googlegroups.com


On Wednesday, April 2, 2014 7:49:07 AM UTC-4, Jakub Holy wrote:
When starting lein (namely lein ring server) I got a little helpful exception and stack trace with the key line being:

FileNotFoundException: Could not locate clojure/tools/namespace/parse__init.class or clojure/tools/namespace/parse.clj on classpath


This could be caused by different libraries or plugins depending on different versions of tools.namespace.

clojure.tools.namespace.parse is present starting with tools.namespace version 0.2.0.

Note: In tools.namespace version 0.2.0 I removed the namespace `clojure.tools.namespace` which was present in 0.1.x. After learning that this caused problems, I added the deprecated namespace back in version 0.2.1.

You can use `lein deps :tree` to figure out which version is getting included in your project.

You can add an explicit dependency in your project.clj on a version that you know is compatible with all the libraries/plugins you want to use.

In this case, the latest version of tools.namespace is backwards compatible with 0.1.X versions. If that were not the case, you'd be out of luck.

 

Jakub Holy

unread,
Apr 4, 2014, 4:52:40 AM4/4/14
to clo...@googlegroups.com
Thank you all!

@Stuart Great to know that 0.2.1 is backwards compatible.

@Sean You are right about running it separately. But I am lazy and it is easier to be able to just run (sdoc) from repl and get the ns browser up. On the other hand, it is perhaps not so smart to pollute one's profile with all possible tools and then spend hours debugging conflicts :)


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/h3U0zx9kEvo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages