clojurewerkz / spyglass

A Clojure Memcached client (also: Couchbase, Kestrel). Built on top of SpyMemcached, supports ASCII and binary protocols, strives to be 100% feature complete.
http://clojurememcached.info
67 stars 16 forks source link

Null Pointer Exception on use of lib #3

Closed mvid closed 11 years ago

mvid commented 12 years ago

When compiling, I get this trace:

WARNING: flush already refers to: #'clojure.core/flush in namespace: clojurewerkz.spyglass.client, being replaced by: #'clojurewerkz.spyglass.client/flush Exception in thread "main" java.lang.NullPointerException, compiling:(stinger.clj:1) at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3342) at clojure.lang.Compiler.compile1(Compiler.java:6985) at clojure.lang.Compiler.compile1(Compiler.java:6975) at clojure.lang.Compiler.compile(Compiler.java:7046) at clojure.lang.RT.compile(RT.java:385) at clojure.lang.RT.load(RT.java:425) at clojure.lang.RT.load(RT.java:398) at clojure.core$load$fn__4610.invoke(core.clj:5386) at clojure.core$load.doInvoke(core.clj:5385) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5200) at clojure.core$load_lib.doInvoke(core.clj:5237) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:602) at clojure.core$load_libs.doInvoke(core.clj:5271) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:602) at clojure.core$require.doInvoke(core.clj:5352) at clojure.lang.RestFn.invoke(RestFn.java:421) at credits.core$loading__4505__auto__.invoke(core.clj:1) at clojure.lang.AFn.applyToHelper(AFn.java:159) at clojure.lang.AFn.applyTo(AFn.java:151) at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3337) at clojure.lang.Compiler.compile1(Compiler.java:6985) at clojure.lang.Compiler.compile1(Compiler.java:6975) at clojure.lang.Compiler.compile(Compiler.java:7046) at clojure.lang.RT.compile(RT.java:385) at clojure.lang.RT.load(RT.java:425) at clojure.lang.RT.load(RT.java:398) at clojure.core$load$fn__4610.invoke(core.clj:5386) at clojure.core$load.doInvoke(core.clj:5385) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5200) at clojure.core$compile$fn__4615.invoke(core.clj:5397) at clojure.core$compile.invoke(core.clj:5396) at user$eval31.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.NullPointerException at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4728) at clojure.lang.Compiler$DefExpr.emit(Compiler.java:395) at clojure.lang.Compiler.compile1(Compiler.java:6984) at clojure.lang.Compiler.compile(Compiler.java:7046) at clojure.lang.RT.compile(RT.java:385) at clojure.lang.RT.load(RT.java:425) at clojure.lang.RT.load(RT.java:398) at clojure.core$load$fn__4610.invoke(core.clj:5386) at clojure.core$load.doInvoke(core.clj:5385) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invoke(core.clj:5200) at clojure.core$load_lib.doInvoke(core.clj:5237) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invoke(core.clj:602) at clojure.core$load_libs.doInvoke(core.clj:5271) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invoke(core.clj:602) at clojure.core$require.doInvoke(core.clj:5352) at clojure.lang.RestFn.invoke(RestFn.java:457) at credits.stinger$loading__4505__auto__.invoke(stinger.clj:1) at clojure.lang.AFn.applyToHelper(AFn.java:159) at clojure.lang.AFn.applyTo(AFn.java:151) at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3337)

Seems to have to do with overwriting the function "flush". Any ideas?

michaelklishin commented 12 years ago

The exception is in stinger.clj:1, which is not a library namespace. Do you mind posting your code, at least the way you use the ns macro? I suspect that you are not using it correctly.

michaelklishin commented 12 years ago

The clojure.core/flush warning is a red herring.

michaelklishin commented 12 years ago

What I recommend you to do is to just use ns macro uses from the Getting Started guide if you are new to Clojure. That's why many examples have it.

mvid commented 12 years ago

http://dpaste.org/Wwsww/ that is the code. Nothing special, already uses the ns macro.

michaelklishin commented 12 years ago

The ns macro looks alright but I have doubts it has anything to do with Spyglass. What happens if you take all the code related to it out? Can you open source or send me your entire project?

mvid commented 12 years ago

When I remove all of the code, my tests pass and it compiles no problem.

Modified: http://dpaste.org/HaxBY/

apage43 commented 12 years ago

The problem is that Spyglass for some reason breaks if any namespace that is AOT compiled depends on it. In this case it looks like credits.core is being AOT'd (probably because it's the project main) and depends on credits.stringer.

Here's an example project that fails in the same way: https://gist.github.com/3626476

Check it out and attempt to do lein run

michaelklishin commented 12 years ago

@apage43 thanks!

michaelklishin commented 12 years ago

The issue turned out to be that clojurewerkz.spyglass.client shadowed clojure.core/replace. Apparently that function is used by the gen-class machinery. I haven't gotten to the bottom of it and still not sure why exactly scoping seems to matter to it but it's a good idea to fix that anyway.

Should be fixed in 1.0.2 and master.

Navgeet commented 9 years ago

@michaelklishin Can you update clojurememcached.info with the version number. Just tripped on this.

michaelklishin commented 9 years ago

The docs are open source. Please submit a PR if needed. I will do a deploy over the w/e. Sorry about your troubles.

Navgeet commented 9 years ago

@michaelklishin the docs already seem up to date. Seems like just the website is old.