404s when deploying noir war with a berth in compression

I have a feeling that I missed something obvious here, but I don’t know where to start.

I have a new noir application created this way:

$ lein noir new hiworld 

I add a new page handler in src / hiworld / server.clj:

 (ns hiworld.server (:require [noir.server :as server])) (server/load-views "src/hiworld/views/") (def handler (server/gen-handler {:mode :dev :ns 'hiworld})) 

I set project.clj for the ring:

 (defproject hiworld "0.1.0-SNAPSHOT" :description "FIXME: write this!" :dependencies [[org.clojure/clojure "1.3.0"] [noir "1.2.2-SNAPSHOT"]] :dev-dependencies [[lein-ring "0.5.4"]] :ring {:handler hiworld.server/handler} :main hiworld.server) 

Check that it works locally:

 $ lein deps $ lein ring server-headless # elsewhere $ curl -I localhost:3000/welcome HTTP/1.1 200 OK Date: Mon, 20 Feb 2012 08:51:15 GMT Set-Cookie: ring-session=ef00a7ad-2061-4026-9d94-3ed86ec8c46c;Path=/ Content-Type: text/html; charset=utf-8 Content-Length: 0 Server: Jetty(6.1.25) 

I am creating a war:

 $ lein ring uberwar # builds hiworld-0.1.0-SNAPSHOT-standalone.war 

All still. Now I divorce him on the pier:

 $ sudo apt-get install jetty libjetty-extra $ sudo cp hiworld-0.1.0-SNAPSHOT-standalone.war /usr/share/jetty/webapps/root.war $ sudo chown jetty:adm /usr/share/jetty/webapps/root.war $ sudo mv /usr/share/jetty/webapps/root /usr/share/jetty/webapps/root-orig $ sudo /etc/init.d/jetty restart 

But:

 $ curl -I localhost:8080/welcome HTTP/1.1 404 Not Found Date: Mon, 20 Feb 2012 08:59:27 GMT Set-Cookie: ring-session=c255da15-6cbd-4d2c-8e17-9d120918bde9;Path=/ Content-Type: text/html; charset=utf-8 Content-Length: 363 Server: Jetty(6.1.24) 

What did I miss? As far as I can tell, this should be all I need to do to deploy the trivial web application to the marina, but obviously I have something wrong here. I don't mind restarting, so I don't think I need to define my own context - or am I?

UPDATE

I followed this sequence of instructions to create a simple “welcome world” that did not include clojure at all, and it worked as expected, so there is something not entirely correct on the clojure stack.

UPDATED AGAIN

I created the simplest possible application for calls as an autonomous war and deployed it. It worked, so it looks like something noir-specific.

UPDATED THIRD TIME

I created and deployed a hello-world compojure application that worked as expected.

+6
source share
2 answers

I also had this problem. I found the solution on the Noir mailing list here .

In server.clj I did two things: I deleted the call (server/loadviews) and added my views to the required namespaces.

Then I built the project using the lein ring uberwar warname.war .

+2
source

In the .war file, the server / load -views does not work because it cannot find physical files in the war. Hiworld / server.clj just requires all the namespaces that provide the views.

This is not explained in the docs, but I found the mailing list thread explaining what was wrong.

+3
source

Source: https://habr.com/ru/post/908872/


All Articles