0

I have a clojure project in which i used the hiccup library. I want to ask does it work in a similar way as normal clojure and jsp projects ? When i am hosting it on a tomcat server and trying to run it on the web, file not found error comes.

this is my project.clj file

(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.

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.

N.Singh
  • 53
  • 4
  • You really have to provide the code (or the template) you used, how you deployed to tomcat and the errors and logs you get. SO is about solving concrete programming problems. – cfrick Sep 03 '18 at 07:32

1 Answers1

2

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). 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:

(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.

Alan Thompson
  • 29,276
  • 6
  • 41
  • 48