cch1 / http.async.client

Async Http Client - Clojure
http://cch1.github.com/http.async.client
267 stars 40 forks source link

error when run twit example #19

Closed cocodrino closed 12 years ago

cocodrino commented 13 years ago

Hi!!..I get this error when I run the example:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.NullPointerException (NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5440) at clojure.lang.Compiler.eval(Compiler.java:5415) at clojure.lang.Compiler.eval(Compiler.java:5391) at clojure.core$eval.invoke(core.clj:2382) at clojure.main$eval_opt.invoke(main.clj:235) at clojure.main$initialize.invoke(main.clj:254) at clojure.main$null_opt.invoke(main.clj:279) at clojure.main$main.doInvoke(main.clj:354) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:369) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:482) at clojure.main.main(main.java:37) Caused by: java.lang.NullPointerException at user$eval26.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5424) ... 12 more

what can I do?..thanks

neotyk commented 13 years ago

Twitter example was built with old version. Now there is no implicit client, you have to create it by hand with http.async.client/create-client

neotyk commented 13 years ago

I've created a gist that works good with newest version: https://gist.github.com/1090238 Let me know if it solves your problem.

cocodrino commented 13 years ago

actually..I get the same error with this code...I think than problem is slf4j whe I type

lein install I get SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Copying 8 files Wrote pom.xml [INFO] Installing

when I run I get: lein run SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.NullPointerException (NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5440) at clojure.lang.Compiler.eval(Compiler.java:5415) at clojure.lang.Compiler.eval(Compiler.java:5391) at clojure.core$eval.invoke(core.clj:2382) at clojure.main$eval_opt.invoke(main.clj:235) at clojure.main$initialize.invoke(main.clj:254) at clojure.main$null_opt.invoke(main.clj:279) at clojure.main$main.doInvoke(main.clj:354) at clojure.lang.RestFn.invoke(RestFn.java:421) at clojure.lang.Var.invoke(Var.java:369) at clojure.lang.AFn.applyToHelper(AFn.java:163) at clojure.lang.Var.applyTo(Var.java:482) at clojure.main.main(main.java:37) Caused by: java.lang.NullPointerException at user$eval5.invoke(NO_SOURCE_FILE:1) at clojure.lang.Compiler.eval(Compiler.java:5424) ... 12 more

I hope than this error be more clear for you than for me :S thanks

neotyk commented 13 years ago

slf4j is not an issue here, since you don't have implementation of slf4j you will not see any logs from async client.

Please anser following questions:

  1. what version of http.async.client are you using?
  2. have you changed credentials in sample code from gist?
  3. which function are you calling after compilation (statuses-sample/statuses-filter)?
cocodrino commented 13 years ago

Hi noetyk..thanks for the fast answer

1- my depedencies are:

.... :dependencies [[org.clojure/clojure "1.2.1"] [http.async.client "0.3.1"] [org.danlarkin/clojure-json "1.2-SNAPSHOT"] [org.clojars.jhowarth/clojure-contrib "1.2.0-RC3"]]

:dev-dependencies [[swank-clojure "1.2.1"]])

2 yes I'm using my account

and 3...I'm calling statuses-filter but I've tried with sample too

I get this error:

lein run SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread "main" java.lang.RuntimeException: java.lang.Exception: EOF while reading (core.clj:1) at clojure.lang.Compiler.eval(Compiler.java:5440) ...

neotyk commented 13 years ago

Those samples for brevity assume valid response from Twitter. Which looking at you last exception is not the case (json parser EOF..)

Change:

        user %28:screen_name %28:user twit%29%29
        text %28:text twit%29]
    %28println prefix ":" user "=>" text)))

into:

  (println "parsing:" s)
  (let [twit (j/decode-from-str s)
        user (:screen_name (:user twit))
        text (:text twit)]
    (println prefix ":" user "=>" text)))

This will show you what you've received in body from twitter. It is not really a solution to problem, code should take care of error conditions, but this will help identifying what is going wrong.

neotyk commented 13 years ago

Is it still an issue or can I close this issue already?