Hi all,
Following the "Getting Started" instructions on
http://webnoir.org/, I
managed to install noir and run my first app with a minor modification:
I added '
:gen-class' to '
servlet.clj'
to have a working uberjar. Everything went fine on my laptop. As the
next step, I decided to run the *same* uberjar on my VPS and to my
surprise it did *not* work! Any URL I tried bounced back with a 404 while strangely enough the stylesheets for the 404 page were correctly loaded and the page was displayed with a dark background and a green'ish theme. Both laptop and VPS run the same version of
JDK (1.6.0_26) on Linux. The only differences I can think of is that VPS is a 32-bit machine and
has a static valid IP while the laptop is a 64-bit machine with no static valid IP.
What am I doing wrong? Am I missing something obvious? Any hint/help is much appreciated.
TIA,
==== project.clj ====
(defproject arvand "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.3.0"]
[noir "1.2.2"]]
:uberjar-name "arvand.jar"
:main arvand.server)
==== server.clj ====
(ns arvand.server
(:require [noir.server :as server])
(:gen-class))
(server/load-views "src/arvand/views/")
(defn -main [& m]
(let [mode (keyword (or (first m) :dev))
port (Integer. (get (System/getenv) "PORT" "8080"))]
(server/start port {:mode mode
:ns 'arvand})))
==== Lein output ====
$ lein clean && lein uberjar
Copying 31 files to /home/bahman/Work/arvand/lib
Compiling arvand.server
Compilation succeeded.
Created /home/bahman/Work/arvand/arvand-0.1.0-SNAPSHOT.jar
Including arvand-0.1.0-SNAPSHOT.jar
Including tools.macro-0.1.0.jar
Including clojure-1.3.0.jar
Including core.incubator-0.1.0.jar
Including commons-fileupload-1.2.1.jar
Including hiccup-0.3.7.jar
Including servlet-api-2.5-20081211.jar
Including clj-json-0.4.3.jar
Including commons-codec-1.3.jar
Including java.classpath-0.1.0.jar
Including commons-httpclient-3.1.jar
Including noir-1.2.2.jar
Including ring-servlet-1.0.1.jar
Including tools.namespace-0.1.0.jar
Including ring-reload-modified-0.1.1.jar
Including clout-1.0.0.jar
Including ring-1.0.1.jar
Including jetty-util-6.1.25.jar
Including commons-logging-1.1.1.jar
Including jackson-core-asl-1.5.0.jar
Including jets3t-0.8.1.jar
Including servlet-api-2.5.jar
Including ring-jetty-adapter-1.0.1.jar
Including ns-tracker-0.1.1.jar
Including ring-devel-1.0.1.jar
Including jbcrypt-0.3m.jar
Including clj-stacktrace-0.2.3.jar
Including commons-io-1.4.jar
Including ring-core-1.0.1.jar
Including jetty-6.1.25.jar
Including java-xmlbuilder-0.4.jar
Including compojure-1.0.0.jar
Created /home/bahman/Work/arvand/arvand.jar
==== Output on VPS ====
$ java -jar arvand.jar
Starting server...
2012-04-15 06:38:51.940:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
2012-04-15 06:38:51.941:INFO::jetty-6.1.x
2012-04-15 06:38:51.952:INFO::Started
SocketC...@0.0.0.0:8080Server started on port [8080].
You can view the site at
http://localhost:8080$ wget
http://localhost:8080/--2012-04-15 06:38:56--
http://localhost:8080/Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8080... connected.
HTTP request sent, awaiting response... 404 Not Found
2012-04-15 06:38:56 ERROR 404: Not Found.
$ wget
http://localhost:8080/welcome--2012-04-15 06:38:56--
http://localhost:8080/welcomeResolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8080... connected.
HTTP request sent, awaiting response... 404 Not Found
2012-04-15 06:38:58 ERROR 404: Not Found.
--
Bahman