简体   繁体   English

如何在tomcat上托管打ic clojure项目?

[英]how to host my hiccup clojure project on tomcat?

I have a clojure project in which i used the hiccup library. 我有一个Clojure项目,在其中使用了打ic库。 I want to ask does it work in a similar way as normal clojure and jsp projects ? 我想问一下,它的工作方式与普通clojure和jsp项目类似吗? When i am hosting it on a tomcat server and trying to run it on the web, file not found error comes. 当我将其托管在tomcat服务器上并尝试在网络上运行时,出现文件未找到错误。

this is my project.clj file 这是我的project.clj文件

(defproject web-app "0.1.0-SNAPSHOT"  
:description "FIXME: write description"  
:url "http://example.com/FIXME"  
:license {:name "Eclipse Public License"  
        :url "http://www.eclipse.org/legal/epl-v10.html"}  
:dependencies [[org.clojure/clojure "1.8.0"]  
             [clj-jgit "0.8.10"]  
             [org.clojure/data.json "0.2.6"]  
             [clj-yaml "0.4.0"]  
             [io.forward/yaml "1.0.9"]  
             [hiccup "1.0.5"]  
             [compojure "1.6.1"]  
             [ring/ring-core "1.6.3"]  
             [ring/ring-defaults "0.3.2"]  
             [ring/ring-jetty-adapter "1.6.3"]]    
  :plugins [[lein-ring "0.12.4"]]  

 :ring {:handler handler.core/-main}  
 :main handler.core)

this is my handler namespace 这是我的处理程序名称空间

(ns handler.core  
(:require [layout.core :as veiw_mapper]  
        [web-app.core ]  
        [compojure.core :refer :all]  
        [compojure.route :as route]  
        [ring.adapter.jetty :as jetty]  
        [ring.middleware.defaults :refer [wrap-defaults site-defaults]])  
  (:gen-class))  
 (defroutes app-routes  
 (GET "/" [] (veiw_mapper/index))  
(POST "/" [& params] (web-app.core/update-mapper params))  
       ;;(POST "/about" [] ())  
(route/resources "//")  
(route/not-found "Not Found"))  

(def app  
(wrap-defaults app-routes site-defaults))  

(defn -main[]  
 )

i am making the war file and pasting it into the webapps folder and then running the tomcat server. 我正在制作war文件并将其粘贴到webapps文件夹中,然后运行tomcat服务器。

Type Exception Report

Message No matching ctor found for class java.lang.Integer

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

    Exception 
java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Integer
    clojure.lang.Reflector.invokeConstructor(Reflector.java:183)
    handler.core$_main.invokeStatic(core.clj:21)
    handler.core$_main.doInvoke(core.clj:19)
    clojure.lang.RestFn.invoke(RestFn.java:408)
    clojure.lang.Var.invoke(Var.java:379)
    handler.listener$_contextInitialized$fn__11.invoke(listener.clj:1)
    ring.util.servlet$make_service_method$fn__3668.invoke(servlet.clj:129)
    handler.servlet$_service.invokeStatic(servlet.clj:1)
    handler.servlet$_service.invoke(servlet.clj:1)
    handler.servlet.service(Unknown Source)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

this is the error which comes. 这就是随之而来的错误。

One hint is the Exception you got: 一个提示是您得到的异常:

java.lang.IllegalArgumentException: No matching ctor found for class java.lang.Integer

So it is trying to construct an Integer but can't find the right constructor (ctor). 因此,它正在尝试构造一个Integer但找不到正确的构造函数(ctor)。 This probably means a garbage value was supplied someplace it expected an integer. 这可能意味着在某个期望整数的地方提供了垃圾值。 For example: 例如:

> (Integer. {})   ; can't construct an Integer from an empty map
IllegalArgumentException No matching ctor found for class java.lang.Integer  clojure.lang.Reflector.invokeConstructor (Reflector.java:183)

Another hint is a mispelled view : 另一个提示是拼写错误的view

(GET "/" [] (veiw_mapper/index))

The best approach is to find a working example, get it working on your machine, and then add in just 1-3 new lines at a time until you get it working. 最好的方法是找到一个有效的示例,使其在您的计算机上正常工作,然后一次仅添加1-3行,直到您可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM