Skip to content

Unable to pass a function written in built.boot to :not-found #66

@kennyjwilli

Description

@kennyjwilli

If my :not-found handler function is written in my build.boot file then I will get the below error:

java.lang.Thread.run                  Thread.java:  745
         java.util.concurrent.ThreadPoolExecutor$Worker.run      ThreadPoolExecutor.java:  617
          java.util.concurrent.ThreadPoolExecutor.runWorker      ThreadPoolExecutor.java: 1142
                        java.util.concurrent.FutureTask.run              FutureTask.java:  266
                                                        ...                                   
                        clojure.core/binding-conveyor-fn/fn                     core.clj: 2027
                                          boot.core/boot/fn                     core.clj: 1029
                                        boot.core/run-tasks                     core.clj: 1019
                        pandeiro.boot-http/eval902/fn/fn/fn                boot_http.clj:  112
                                         clojure.core/deref                     core.clj: 2317
                                                        ...                                   
                           pandeiro.boot-http/eval902/fn/fn                boot_http.clj:   77
                                          boot.pod/eval-in*                      pod.clj:  471
                                                        ...                                   
org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.invoke  ClojureRuntimeShimImpl.java:  102
org.projectodd.shimdandy.impl.ClojureRuntimeShimImpl.invoke  ClojureRuntimeShimImpl.java:  109
                                                        ...                                   
                                          boot.pod/eval-in*                      pod.clj:  468
                                          clojure.core/eval                     core.clj: 3194
                                                        ...                                   
                             pandeiro.boot-http.impl/server                     impl.clj:  142
                       pandeiro.boot-http.impl/ring-handler                     impl.clj:  118
                        pandeiro.boot-http.impl/dir-handler                     impl.clj:   90
                     pandeiro.boot-http.impl/wrap-not-found                     impl.clj:   82
                        pandeiro.boot-http.util/resolve-sym                     util.clj:    4
                                        clojure.core/symbol                     core.clj:  579
                                                        ...                                   
         java.lang.NullPointerException: 
clojure.lang.Compiler$CompilerException: java.lang.NullPointerException, compiling:(NO_SOURCE_FILE:0:0)
             clojure.lang.ExceptionInfo: java.lang.NullPointerException, compiling:(NO_SOURCE_FILE:0:0)
    file: "/tmp/boot.user7518152912469497163.clj"
    line: 35

Here is my example task I am calling:

(defn not-found-handler
  [req]
  {:status  404
   :headers {}
   :body    "Not found"})

(deftask start-server
         []
         (comp
           (serve :not-found 'not-found-handler)
           (wait)))

Not quite sure what the cause of this error is. It must be something boot specific. If I move my handler into a clj file in my project, then it works correctly - no error thrown. Example:

(ns myns.core)

(defn not-found-handler
  [req]
  {:status  404
   :headers {}
   :body    "Not found"})
;; build.boot
(require '[myns.core :as core])

(deftask start-server
         []
         (comp
           (serve :not-found 'core/not-found-handler)
           (wait)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions