I created a WAR sample, as shown on the Compajure Getting Started page , and deployed it to the Apache Tomcat 6.0.2 wepapps folder. The Web.xml I use looks like this:
<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 causes 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 tabs Clojure, Clojure contrib in the WEB-INF / lib folder.
Has anyone encountered a similar issue with Clojure WARs on Apache Tomcat?
The servlet I'm 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 (defservice greeter)with
(run-server {:port 8080}
"/*" (servlet greeter))
I can run this and access the URL from the browser.
However, when I run this from Apache Tomcat, I still encounter the same problem.