You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a user tries to visit /img/ instead of /img/dog.jpg the browser hangs and an exception shows up under lein ring. Shouldn't route/resource return nil in this case and let some other handler take care of this? This would allow the default handler to send back a 404 http reply.
2011-10-05 09:40:01.600:WARN::/img/
java.io.FileNotFoundException: /home/afonso/clojure/resume/tin-can/compojure-experiment/resources/public (Is a directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:137)
at ring.util.servlet$set_body.invoke(servlet.clj:78)
at ring.util.servlet$update_servlet_response.invoke(servlet.clj:108)
at ring.adapter.jetty$proxy_handler$fn__77.invoke(jetty.clj:18)
at ring.adapter.jetty.proxy$org.mortbay.jetty.handler.AbstractHandler$0.handle(Unknown Source)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
The text was updated successfully, but these errors were encountered:
I've just encountered the same problem. In my case, it was caused by me dropping the explicit mapping for "/" from my routes. Rather than then giving me a not-found, which was the next rule, it tries to read the resources directory as a file. Yes, I have
(route/resource "/")
(route/not-found "Page not found")
When a user tries to visit /img/ instead of /img/dog.jpg the browser hangs and an exception shows up under lein ring. Shouldn't route/resource return nil in this case and let some other handler take care of this? This would allow the default handler to send back a 404 http reply.
Here is the project.clj file:
(defproject compojure-experiment "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.2.1"]
[compojure "0.6.5"]]
:dev-dependencies [[lein-ring "0.4.5"]]
:ring {:handler compojure-experiment.core/app})
Here is compojure-experiment/core.clj:
(ns compojure-experiment.core
(:use compojure.core)
(:require [compojure.route :as route]
[compojure.handler :as handler]))
(defroutes main-routes
(GET "/" [] "<h1>Fee fi fo fum</h1>")
(route/resources "/img/")
(route/resources "/css/")
(route/not-found "<h1>No such page, fool.</h1>"))
(def app
(handler/site main-routes))
Here is the url:
http://127.0.0.1:3000/img/
Here is the stack trace:
2011-10-05 09:40:01.600:WARN::/img/
java.io.FileNotFoundException: /home/afonso/clojure/resume/tin-can/compojure-experiment/resources/public (Is a directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:137)
at ring.util.servlet$set_body.invoke(servlet.clj:78)
at ring.util.servlet$update_servlet_response.invoke(servlet.clj:108)
at ring.adapter.jetty$proxy_handler$fn__77.invoke(jetty.clj:18)
at ring.adapter.jetty.proxy$org.mortbay.jetty.handler.AbstractHandler$0.handle(Unknown Source)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
The text was updated successfully, but these errors were encountered: