IntelliJ 中的 Clojure Web 应用程序梅文 +雄猫

发布于 2025-01-01 17:19:06 字数 1934 浏览 4 评论 0 原文

我正在 IntelliJ 中使用 Maven 作为依赖管理器,使用基于 Compojure 的 Clojure Web 应用程序。它基于我在 git 存储库中找到的应用程序“http://assenkolov.blogspot.com/2011/11/sample-clojurecompojure-web-application.html”rel =“nofollow noreferrer”>此示例。当我尝试使用 IntelliJ 的 Tomcat6 配置运行应用程序时,每次都会失败并引用 Servlet 异常:

javax.servlet.ServletException: Wrapper cannot find servlet class tracker.core or a class it depends on

另外查看 web.xml,IntelliJ 无法识别 servlet 类(tracker.core 突出显示)。 >

一点背景知识:

该应用程序最初是作为客户的概念验证而构建的,由我最近离开公司的同事编写。除了过去两天的这个项目工作之外,我个人对 clojure 没有什么经验。使用 Leiningen 环服务器,我可以成功地让应用程序在码头上运行。使用leiningen Ring uberwar,生成的war成功部署并在tomcat中运行。

原始文件结构如下所示:

/tracker-webapp  
    /classes
    /lib
    /resources
    /src
        /tracker
            /core.clj (and other *.clj files)
    /test
    project.clj

新的 mavenized 文件结构现在反映了前面提到的 git 存储库中的示例:

/tracker-webapp
    /src
        /main
            /clojure
                /tracker
                    /core.clj (and other *.clj files)
            /webapp
                /WEB-INF
                    /web.xml
    /pom.xml

我的 web.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>

其他资源

我本来打算发布我在本节中查看过的其他资源,但自从我是 Stack Overflow 新手,我只得到两个链接:/

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).

A little background:

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

My web.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>

Other Resources

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 :/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

-柠檬树下少年和吉他 2025-01-08 17:19:06

您需要提前编译 clojure 命名空间 tracker.core (AOT)。我不确定这是如何使用 Maven 插件完成的,但它为您提供了正确的方向。

确保您的命名空间中有一个 gen-class 声明:

(ns tracker.core
  ;; ...
  (:gen-class :extends javax.servlet.http.HttpServlet))

检查 Intellij/Maven 是否实际在目标目录中生成文件 tracker/core.class。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文