首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NullPointerException时Aleph+Ring上的环形服务器

NullPointerException时Aleph+Ring上的环形服务器
EN

Stack Overflow用户
提问于 2014-06-18 06:59:34
回答 1查看 465关注 0票数 1

我试图运行阿列弗在环的顶部,并使用lein ring server作为较短的反馈回路。

当我调用lein ring server时,一切似乎都很好,但是当我将浏览器指向url时,我会得到一个带有下面堆栈跟踪的讨厌的NullPointerException

但是,当我运行(al.app/start 3006)时,没有出现NLP

整个项目可在GitHub上使用。

我做错了什么?

代码语言:javascript
复制
core.clj:107    lamina.core/enqueue
app.clj:39  al.app/hello-handler
http.clj:79 aleph.http/wrap-aleph-handler[fn]
response.clj:27 compojure.response/eval1328[fn]
response.clj:10 compojure.response/eval1289[fn]
core.clj:93 compojure.core/make-route[fn]
core.clj:39 compojure.core/if-route[fn]
...    

我正在使用aleph 0.3.2,这是我的代码:

代码语言:javascript
复制
(ns al.app
  (:use
      aleph.http
      lamina.core
      compojure.core
      ring.middleware.keyword-params)
 (:require [compojure.route :as route]))

(defn hello-handler                                                                    
  "Our handler for the /hello path"                                                    
  [ch request]                                                                         
  (let [params (:route-params request)                                          
        name (params :name)]                                                           
    (enqueue ch                                                                        
      {:status 200                                                                     
       :headers {}                                                                     
       :body (str "Hello " name)})))                                                   

(defroutes my-routes                                                                   
  (GET ["/hello/:name", :name #"[a-zA-Z]+"] {} (wrap-aleph-handler hello-handler))     
  (route/not-found "Page not found"))                                                  

(defn start                                                                            
    "Start our server in the specified port"                                           
    [port]                                                                             
    (start-http-server (wrap-ring-handler my-routes) {:port port})) 
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-19 13:06:13

Lein插件使用嵌入式Jetty web服务器,而Aleph使用异步Netty web服务器。aleph.http/wrap-aleph-handler中间件的设计仅适用于使用aleph.http/start-http-server函数启动的Netty服务器。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24278946

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档