I am working with a Compojure based Clojure web application in IntelliJ using Maven as my dependency manager. It is based on an application I found at this git repository referenced by this example. When I try to run the application using IntelliJ's Tomcat6 configuration, it fails each time citing a Servlet Exception:
javax.servlet.ServletException: Wrapper cannot find servlet class tracker.core or a class it depends on
Additionally looking at the web.xml, IntelliJ does not recognize the servlet class (tracker.core is highlighted).
This application was originally was built as a proof of concept for a client and written by my coworker who recently left the company. I personally have no experience with clojure beyond working on this project over the last two days. Using Leiningen ring server, I can successfully get the application to run in jetty. Using leiningen ring uberwar, the resulting war successfully deploys and runs in tomcat.
The original file structure looks like so:
/tracker-webapp
/classes
/lib
/resources
/src
/tracker
/core.clj (and other *.clj files)
/test
project.clj
The new mavenized file structure now mirrors the example in the previously mentioned git repo:
/tracker-webapp
/src
/main
/clojure
/tracker
/core.clj (and other *.clj files)
/webapp
/WEB-INF
/web.xml
/pom.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Simple Clojure WebApp</display-name>
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>tracker.core</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
I was going to post the other resources that I've looked at in this section but since I'm a Stack Overflow Newb I only get two links :/
You need to compile your clojure namespace tracker.core ahead-of-time (AOT). I'm not sure how this is done with the maven plugin but it gives you the right direction.
Make sure that you have a gen-class declaration in your namespace:
(ns tracker.core
;; ...
(:gen-class :extends javax.servlet.http.HttpServlet))
Check that Intellij/Maven actually produce the file tracker/core.class in the target directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With