[noir] making WAR by ring uberwar

345 views
Skip to first unread message

Jonguk Kim

unread,
Dec 16, 2011, 12:52:32 PM12/16/11
to clj-noir
Hi,

I want to make a WAR from my noir project.
I've read this thread: http://groups.google.com/group/clj-noir/browse_thread/thread/40d13319f4bcb944
and I think I did all setting correctly but I got an error.

I did 'lein deps & lein clean'. FYI, I'm using Windows 7. (I want to
use Ubuntu but my netbook dislike it :P)

Here is my code snips and error message. What's my mistake?

project.clj:

(defproject webapp-by-noir "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:dependencies [[org.clojure/clojure "1.3.0"]
[noir "1.2.1"]]
:dev-dependencies [[com.github.robertrolandorg/lein-eclipse "1.1.0"]
[lein-ring "0.5.0"]]
:ring {:handler webapp-by-noir.server/handler}
:main webapp-by-noir.server)

server.clj:

(ns webapp-by-noir.server
(:require [noir.server :as server]))

(server/load-views "src/webapp_by_noir/views/")

(def handler (server/gen-handler {:ns 'webapp-by-noir}))

(defn -main [& m]
(let [mode (keyword (or (first m) :dev))
port (Integer. (get (System/getenv) "PORT" "8080"))]
(server/start port {:mode mode
:ns 'webapp-by-noir})))

Error message:

Exception in thread "main" java.util.zip.ZipException: duplicate
entry: WEB-INF/classes/webapp_by_noir/server.clj (NO_SO
URCE_FILE:0)
at clojure.lang.Compiler.eval(Compiler.java:5440)
at clojure.lang.Compiler.eval(Compiler.java:5391)
at clojure.core$eval.invoke(core.clj:2382)
at clojure.main$eval_opt.invoke(main.clj:235)
at clojure.main$initialize.invoke(main.clj:254)
at clojure.main$script_opt.invoke(main.clj:270)
at clojure.main$main.doInvoke(main.clj:354)
at clojure.lang.RestFn.invoke(RestFn.java:482)
at clojure.lang.Var.invoke(Var.java:381)
at clojure.lang.AFn.applyToHelper(AFn.java:178)
at clojure.lang.Var.applyTo(Var.java:482)
at clojure.main.main(main.java:37)
Caused by: java.util.zip.ZipException: duplicate entry: WEB-INF/
classes/webapp_by_noir/server.clj
at java.util.zip.ZipOutputStream.putNextEntry(Unknown Source)
...

Thanks.

Chris Granger

unread,
Dec 16, 2011, 1:08:28 PM12/16/11
to clj-...@googlegroups.com
I'm not sure, but this was actually brought up on the Leiningen group just the other day: http://groups.google.com/group/leiningen/browse_thread/thread/74c5c225eb9bf349

As James says, that exception means that somehow there are two of the same file on your path. Not sure how that could be true in your case, though.

Cheers,
Chris.

Jonguk Kim

unread,
Dec 17, 2011, 12:12:42 AM12/17/11
to clj-...@googlegroups.com
I asked on Leiningen list and got the answer. Thanks.

One more question.

I made a WAR and deploy my Tomcat server on FreeBSD box.
Sadly, I got a HTTP 500 error.

Error message:
java.io.FileNotFoundException:
/usr/local/apache-tomcat-7.0/webapps/webapp-by-noir-0.1.0-standalone/WEB-INF/classes/public
(Is a directory)
java.io.FileInputStream.open(Native Method)
java.io.FileInputStream.<init>(FileInputStream.java:106)
ring.util.servlet$set_body.invoke(servlet.clj:96)
ring.util.servlet$update_servlet_response.invoke(servlet.clj:124)
ring.util.servlet$make_service_method$fn__723.invoke(servlet.clj:140)
webapp_by_noir.servlet$_service.invoke(servlet.clj:1)
webapp_by_noir.servlet.service(Unknown Source)

In my FreeBSD box,
/usr/local/apache-tomcat-7.0/webapps/webapp-by-noir-0.1.0-standalone/WEB-INF/classes/public
directory actually exists.
I'm wondering why this error occurs.
Any ideas?

Jonguk

James Reeves

unread,
Dec 17, 2011, 8:53:40 AM12/17/11
to clj-...@googlegroups.com
On 17 December 2011 05:12, Jonguk Kim <sun...@gmail.com> wrote:
> I made a WAR and deploy my Tomcat server on FreeBSD box.
> Sadly, I got a HTTP 500 error.
>
> Error message:
> java.io.FileNotFoundException:
> /usr/local/apache-tomcat-7.0/webapps/webapp-by-noir-0.1.0-standalone/WEB-INF/classes/public
> (Is a directory)
>
> In my FreeBSD box,
> /usr/local/apache-tomcat-7.0/webapps/webapp-by-noir-0.1.0-standalone/WEB-INF/classes/public
> directory actually exists.
> I'm wondering why this error occurs.

It sounds as if you''re trying to create a resource response from a
directory. Were you expecting it to return an "index.html" file?

- James

Jonguk Kim

unread,
Dec 17, 2011, 12:30:21 PM12/17/11
to clj-...@googlegroups.com
Hmm. I don't know.
My WAR includes noir's default files (I mean, files that created when
'lein noir new ...' executes.
I did not change them much. Some changes in common.clj. I deleted welcome.clj.

In 'public' directory, there is 'css' directory and 'reset.css' exists.

Thank you for reading.

Jonguk.

James Reeves

unread,
Dec 17, 2011, 12:34:39 PM12/17/11
to clj-...@googlegroups.com
On 17 December 2011 17:30, Jonguk Kim <sun...@gmail.com> wrote:
> Hmm. I don't know.
> My WAR includes noir's default files (I mean, files that created when
> 'lein noir new ...' executes.
> I did not change them much. Some changes in common.clj. I deleted welcome.clj.
>
> In 'public' directory, there is 'css' directory and 'reset.css' exists.

It kinda sounds like it's not finding your root route for some reason.

- James

Mark Rathwell

unread,
Dec 17, 2011, 1:29:54 PM12/17/11
to clj-...@googlegroups.com
Two questions:

1. Did you set the ring handler in your project.clj before running
lein uberwar? (e.g. :ring {:handler myns/myapp})
2. Did you manually (require ...) your views?

Jonguk Kim

unread,
Dec 17, 2011, 1:47:03 PM12/17/11
to clj-...@googlegroups.com
1. Yes.
2. I guess not. In my server.clj, there is (server/load-views
"src/webapp_by_noir/views/").

Is this wrong? How should I change?

Jonguk

Mark Rathwell

unread,
Dec 17, 2011, 1:56:58 PM12/17/11
to clj-...@googlegroups.com
In the file that contains the (server/load-views ...) call, remove
that call and and in your ns call, (:require ...) all of your view
namespaces, or you can place (require ...) in place of your
server/load-views ...) call. I believe the reason this is necessary
it that tools.ns cannot find files on the classpath in a war.

** Note, I don't think this is the cause of your 500 error, I thought
you didn't have the ring handler specified in project.clj, this is
just the next issue you would have run into. Is the stacktrace you
posted complete? Can you post the code that is executing when you get
the 500?

Chris Granger

unread,
Dec 17, 2011, 2:02:05 PM12/17/11
to clj-...@googlegroups.com
No no, you guys got it. He's probably using 1.2.1 instead of 1.2.2-SNAPSHOT which has the latest ring stuff in it that fixed the bug with resource routes failing on directories. That does cause a 500, because none of his views were loaded as a result of tools.ns not working correctly in a war.

Cheers,
Chris.

James Reeves

unread,
Dec 17, 2011, 2:10:56 PM12/17/11
to clj-...@googlegroups.com
On 17 December 2011 19:02, Chris Granger <ibd...@gmail.com> wrote:
> No no, you guys got it. He's probably using 1.2.1 instead of 1.2.2-SNAPSHOT
> which has the latest ring stuff in it that fixed the bug with resource
> routes failing on directories.

Oh yes, I'd forgotten about that.

- James

Reply all
Reply to author
Forward
0 new messages