Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil

I'm very new to Clojure and I'm having a great time playing with it. One thing I'm having some trouble with is how to read the errors, I personally think they're not very descriptive, but that's probably due to my "newbieness".

For example, the issue I'm having now is when I try to start up my ring server (I can provide more details if needed):

Started server on port 3000
java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
          core_deftype.clj:544 clojure.core/-cache-protocol-fn
                     io.clj:69 clojure.java.io/fn[fn]
                    io.clj:102 clojure.java.io/reader
               RestFn.java:410 clojure.lang.RestFn.invoke
             validator.clj:161 selmer.validator/validate-tags
             validator.clj:175 selmer.validator/validate
       template_parser.clj:155 selmer.template-parser/read-template
       template_parser.clj:206 selmer.template-parser/preprocess-template
               RestFn.java:410 clojure.lang.RestFn.invoke
                parser.clj:211 selmer.parser/parse-file
                parser.clj:234 selmer.parser/parse
               RestFn.java:442 clojure.lang.RestFn.invoke
                 parser.clj:99 selmer.parser/render-file
               RestFn.java:425 clojure.lang.RestFn.invoke
                 layout.clj:17 picture-gallery.views.layout/picture-gallery.views.layout.RenderablePage
                   core.clj:94 compojure.core/make-route[fn]
                   core.clj:40 compojure.core/if-route[fn]
                   core.clj:25 compojure.core/if-method[fn]
                  core.clj:107 compojure.core/routing[fn]
                 core.clj:2515 clojure.core/some
                  core.clj:107 compojure.core/routing
               RestFn.java:139 clojure.lang.RestFn.applyTo
                  core.clj:626 clojure.core/apply
                  core.clj:112 compojure.core/routes[fn]
                  core.clj:107 compojure.core/routing[fn]
                 core.clj:2515 clojure.core/some
                  core.clj:107 compojure.core/routing
               RestFn.java:139 clojure.lang.RestFn.applyTo
                  core.clj:626 clojure.core/apply
                  core.clj:112 compojure.core/routes[fn]
             middleware.clj:44 noir.util.middleware/wrap-request-map[fn]
         keyword_params.clj:32 ring.middleware.keyword-params/wrap-keyword-params[fn]
          nested_params.clj:70 ring.middleware.nested-params/wrap-nested-params[fn]
                 params.clj:58 ring.middleware.params/wrap-params[fn]
             middleware.clj:12 hiccup.middleware/wrap-base-url[fn]
      multipart_params.clj:107 ring.middleware.multipart-params/wrap-multipart-params[fn]
            middleware.clj:139 noir.util.middleware/wrap-access-rules[fn]
            validation.clj:135 noir.validation/wrap-noir-validation[fn]
                cookies.clj:66 noir.cookies/noir-cookies[fn]
               cookies.clj:171 ring.middleware.cookies/wrap-cookies[fn]
               session.clj:141 noir.session/noir-flash[fn]
                  flash.clj:31 ring.middleware.flash/wrap-flash[fn]
                session.clj:96 noir.session/noir-session[fn]
                session.clj:85 ring.middleware.session/wrap-session[fn]
                  Var.java:379 clojure.lang.Var.invoke
                 reload.clj:18 ring.middleware.reload/wrap-reload[fn]
             stacktrace.clj:17 ring.middleware.stacktrace/wrap-stacktrace-log[fn]
             stacktrace.clj:80 ring.middleware.stacktrace/wrap-stacktrace-web[fn]
                  jetty.clj:18 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:363 org.eclipse.jetty.server.Server.handle
   AbstractHttpConnection.java:483 org.eclipse.jetty.server.AbstractHttpConnection.handleRequest
   AbstractHttpConnection.java:920 org.eclipse.jetty.server.AbstractHttpConnection.headerComplete
   AbstractHttpConnection.java:982 org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete
           HttpParser.java:635 org.eclipse.jetty.http.HttpParser.parseNext
           HttpParser.java:235 org.eclipse.jetty.http.HttpParser.parseAvailable
   AsyncHttpConnection.java:82 org.eclipse.jetty.server.AsyncHttpConnection.handle
SelectChannelEndPoint.java:628 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:722 java.lang.Thread.run

This is so obscure to me, how do I know exactly what I did wrong? I don't remember dealing with any "make-reader", protocols or IOFactory.

like image 333
Gustavo Matias Avatar asked Apr 21 '14 06:04

Gustavo Matias


1 Answers

This is a tricky question to answer without much context. However you seem to be falling foul of http://dev.clojure.org/jira/browse/CLJ-1210 which points out that this error message is distinctly unhelpful!

Please can you look at Clojure Clostache error - No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil which may well be a duplicate. The long and the short of it is that some resource you are referring to does not exist. As a result it is retrieved as "nil" which then results in the trouble you see. Perhaps a case where a library might throw an exception for resource-not-found (or at least have an exception throwing variant).

One of the ways in which I dug around on this was to look at the selmer source code, as that is the first non-clojure.core piece of the stack trace. One of the first things this does is...

(defn validate-tags [template]
    (with-open [rdr (reader template)]

From here some deduction and a quick bit of googling got me to the above.

[2017 update: The unhelpful error was ultimately fixed in Clojure 1.8, so hopefully people will no longer see this issue!]

like image 143
pete23 Avatar answered Oct 16 '22 20:10

pete23