使用resolve调用函数-Clojure

使用resolve调用函数-Clojure,clojure,http-kit,Clojure,Http Kit,我使用resolve调用给定名称(字符串)的函数,如 调用功能: (defn call [this & that] (apply (resolve (symbol this)) that)) 在REPL上一切正常。但是当我使用httpkitttpserver作为服务器启动项目时,我会收到一个NPE java.lang.NullPointerException at clojure.core$apply.invoke(core.clj:626) at tapahtum

我使用
resolve
调用给定名称(字符串)的函数,如

调用
功能:

(defn call [this & that]
  (apply (resolve (symbol this)) that))
在REPL上一切正常。但是当我使用httpkitttpserver作为
服务器启动项目时,我会收到一个NPE

java.lang.NullPointerException
    at clojure.core$apply.invoke(core.clj:626)
    at tapahtuma.http_resources$call.doInvoke(http_resources.clj:41)
    at clojure.lang.RestFn.invoke(RestFn.java:423)
    at tapahtuma.http_resources$forwarder.invoke(http_resources.clj:61)
    at tapahtuma.http_resources$create_event.invoke(http_resources.clj:69)
    at compojure.response$eval1563$fn__1564.invoke(response.clj:26)
    at compojure.response$eval1524$fn__1525$G__1515__1532.invoke(response.clj:10)
    at compojure.core$make_route$fn__1699.invoke(core.clj:93)
    at compojure.core$if_route$fn__1683.invoke(core.clj:39)
    at compojure.core$if_method$fn__1676.invoke(core.clj:24)
    at compojure.core$routing$fn__1705.invoke(core.clj:106)
    at clojure.core$some.invoke(core.clj:2528)
    at compojure.core$routing.doInvoke(core.clj:106)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:628)
    at compojure.core$routes$fn__1709.invoke(core.clj:111)
    at tapahtuma.http_resources$wrap_content_type$fn__7192.invoke(http_resources.clj:22)
    at ring.middleware.cors$wrap_cors$fn__1800.invoke(cors.clj:47)
    at org.httpkit.server.HttpHandler.run(RingHandler.java:33)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
在http_resources
的第41行,我有
call
函数


我不知道这里发生了什么。谢谢你的帮助

以下对复制程序的修改——完全限定名称空间——工作正常:

(defn call [this & that]
  (let [this-sym (symbol this)
        this-resolved (ns-resolve 'resolver-clj.core this-sym)]
     (.println System/out (str "current-ns: " *ns*))
     (.println System/out (str "this-sym: " this-sym))
     (.println System/out (str "this-resolved: " this-resolved))
     (apply this-resolved that)))

当您查看复制环境中
*ns*
的值时,原因是显而易见的,即
clojure.core

您需要多少代码才能添加一个合适的复制器?如果能简明扼要地做到这一点,肯定会有所帮助。@CharlesDuffy我将准备一个项目来重现这个问题。我会尽快在这里发布。Thanks@CharlesDuffymybe这帮人:是的,非常有帮助,谢谢。太好了。谢谢我考虑过ns,但没有进行适当的调查。再次感谢。
(defn call [this & that]
  (let [this-sym (symbol this)
        this-resolved (ns-resolve 'resolver-clj.core this-sym)]
     (.println System/out (str "current-ns: " *ns*))
     (.println System/out (str "this-sym: " this-sym))
     (.println System/out (str "this-resolved: " this-resolved))
     (apply this-resolved that)))