Hi,
I created the sample WAR as given at the Compojure Getting Started Page and deployed it to Apache Tomcat 6.0.2 wepapps folder. The Web.xml I used is as below:
<web-app>
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>myapp.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Accessing the URL throws the following error
java.lang.NullPointerException: Handler returned nil (maybe no routes matched URI)
compojure.http.servlet$request_handler__72.invoke(servlet.clj:110)
myapp.MyServlet$_service__108.invoke(MyServlet.clj:11)
myapp.MyServlet.service(Unknown Source)
I have included the Clojure, Clojure contrib jars in the WEB-INF/lib folder.
Has anyone encountered similar issue with Clojure WARs on Apache Tomcat ?
The Servlet I am trying to run is :
;; src/myapp/MyServlet.clj
(ns myapp.MyServlet
(:use compojure)
(:gen-class
:extends javax.servlet.http.HttpServlet))
(defroutes greeter
(GET "/"
(html [:h1 "Hello World"])))
(defservice greeter)
When I replaced the (defservice greeter)
with
(run-server {:port 8080}
"/*" (servlet greeter))
I am able to run this and access URL from browser.
However, when I run this from Apache Tomcat, I still face the same issue.