Giter Club home page Giter Club logo

lein-ring's Introduction

Lein-Ring

Lein-Ring is a Leiningen plugin that automates common Ring tasks.

It provides commands to start a development web server, and to turn a Ring handler into a standard war file.

Install

To use Lein-Ring, add it as a plugin to your project.clj file or your global profile:

:plugins [[lein-ring "0.12.6"]]

Then add a new :ring key to your project.clj file that contains a map of configuration options. At minimum there must be a :handler key that references your Ring handler:

:ring {:handler hello-world.core/handler}

When this is set, you can use Lein-Ring's commands.

General options

As well as the handler, you can specify several additional options via your project.clj file:

  • :init - A function to be called once before your handler starts. It should take no arguments. If you've compiled your Ring application into a war-file, this function will be called when your handler servlet is first initialized.

  • :destroy - A function called before your handler exits or is unloaded. It should take no arguments. If your Ring application has been compiled into a war-file, then this will be called when your handler servlet is destroyed.

  • :adapter - A map of options to be passed to the Ring adapter. This has no effect if you're deploying your application as a war-file.

  • :async? - If true, treat handler as an async handler. Default false.

Environment variables

Lein-Ring pays attention to several environment variables, including:

  • PORT - the port the web server uses for HTTP
  • SSLPORT - the port the web server uses for HTTPS

These will override any options specified in the project.clj file, but won't override any options specified at the command line.

Starting a web server

The following command will start a development web server, and opens a web browser to the root page:

lein ring server

If the LEIN_NO_DEV environment variable is not set, the server will monitor your source directory for file modifications, and any altered files will automatically be reloaded.

By default, this command attempts to find a free port, starting at 3000, but you can specify your own port as an argument:

lein ring server 4000

The server-headless command works like the server command, except that it doesn't open a web browser:

lein ring server-headless

lein ring server-headless 4000

Web server options

The following options affect the behavior of the web server started by lein ring server:

  • :port - The server port or port range

  • :stacktraces? - If true, display a stacktrace when an exception is thrown. Defaults to true for server or server-headless tasks. Ignored (always false) for generated artifacts.

  • :stacktrace-middleware - A symbol referencing the middleware to use for reporting errors. Defaults to ring.middleware.stacktrace/wrap-stacktrace.

  • :auto-reload? - If true, automatically reload modified source files. Defaults to true for server or server-headless tasks. Ignored (always false) for generated artifacts.

  • :reload-paths - A collection of directory paths that can trigger a reload. By default this takes all directories in the project classpath.

  • :auto-refresh? - If true, automatically refresh the browser when files are modified. Defaults to false. Ignored (always false) for generated artifacts.

  • :refresh-paths - A collection of directory paths that can trigger a refresh. Defaults to monitoring the src and resources directories.

  • :nrepl - A map of :start? and (optionally) :port and :host keys. If :start? is true, open up an nREPL server on the given port. :start? defaults to false, :port defaults to an arbitrary free port, and :host defaults to "localhost". NOTE: This option is only for development with the lein ring server task. Setting this option will not cause a generated uberjar/uberwar to run an nREPL server. If you would like to run an nREPL server in your production app, then see the clojure.tools.nrepl.server project.

Executable jar files

Lein-Ring can generate executable jar files for deployment purposes:

lein ring uberjar

This generates a jar file with all dependencies. You can then copy the file to your web server and execute it with:

java -jar <project>-<version>-standalone.jar

War files

Compiling

Lein-Ring can generate war files that can be loaded onto legacy Java web services such as Apache Tomcat:

lein ring war

A servlet class and web.xml file will be generated automatically, and your application packaged up in a war file.

Like the lein jar command, you can specify the filename being generated as an additional option:

lein ring war my-app.war

Also provided is a lein ring uberwar command, which packages up all the dependencies into the war:

lein ring uberwar

The following war-specific options are supported:

  • :war-exclusions - A list of regular expressions for excluding files from the target war. Defaults to excluding hidden files.

  • :servlet-class - The servlet class name.

  • :servlet-name - The name of the servlet (in web.xml). Defaults to the handler name.

  • :url-pattern - The url pattern of the servlet mapping (in web.xml). Defaults to "/*".

  • :servlet-path-info? - If true, a :path-info key is added to the request map. Defaults to true.

  • :listener-class - Class used for servlet init/destroy functions. Called listener because underneath it uses a ServletContextListener.

  • :web-xml - web.xml file to use in place of auto-generated version (relative to project root).

  • :servlet-version - The version of the servlet spec that we claim to conform to. Attributes corresponding to this version will be added to the web-app element of the web.xml. If not specified, defaults to 2.5.

  • :uberwar-name - The name of the file generated by lein ring uberwar.

  • :exploded - If true, will generate an exploded war directory instead of a war file. If not specified, defaults to false.

These keys should be placed under the :ring key in project.clj, and are optional values. If not supplied, default values will be used instead.

Resources

A war file can also include additional resource files, such as images or stylesheets. These should be placed in the directory specified by the Leiningen :resources-path key, which defaults to "resources". These resources will be placed on the classpath. To include multiple directories, use the Leiningen :resource-paths key, which should be a vector. The values in :resources-path and :resource-paths will be concatenated.

However, there is another sort of resource, one accessed through the ServletContext object. These resources are usually not on the classpath, and are instead placed in the root of the war file. If you happen to need this functionality, you can place your files in the directory specified by the :war-resources-path key (within the project map, rather than the map specified by :ring), which defaults to "war-resources". (As with normal resources, here you can use :war-resource-paths to include multiple directories.) It's recommended that you only use WAR resources for compatibility with legacy Java interfaces; under most circumstances, you should use the normal :resources-path instead.

License

Copyright © 2015 James Reeves, Michael Blume

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

lein-ring's People

Contributors

4xrsjcr9 avatar achin avatar antonmos avatar camsaul avatar cdpjenkins avatar cemerick avatar cloojure avatar danielbraun avatar ddellacosta avatar erdos avatar ericlavigne avatar gfredericks avatar hsartoris-bard avatar ikitommi avatar jalpedersen avatar johnworth avatar juhani-hietikko avatar mattunderscorechampion avatar mbjarland avatar metajack avatar michaelblume avatar mikew1 avatar mwmitchell avatar pittypanda avatar pjstadig avatar technomancy avatar viesti avatar weavejester avatar worrel avatar yogthos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lein-ring's Issues

lein war and uberwar uses absolute path

Hi,

when you package the app up, try not to use /WEB-INF/ etc. as it is an absolute path instead of a relative path. It causes pain on linux if you try to unzip it into the root directory.

otherwise awesome plugin thx

thx

When i change :source-paths option in project.clj autoreload of source files stop working

When i add :source-paths ["src-clj"] to my project.clj. Autoreload of source files stop working.
If i setup :source-paths ["src"] all works fine.

I use Leiningen 2.0.0-preview8

Example of project.clj:
(defproject test "0.2.7" :description "Test" :source-paths ["src-clj"] :dependencies [[org.clojure/clojure "1.4.0"]] :plugins [[lein-ring "0.7.5"]] :ring {:handler example.routes/app :auto-reload? true :port 7777})

FileNotFoundException when path to Tomcat on Windows contains spaces

When I install Tomcat 7 on Windows into a path that contains spaces (the default installation path does), I get a FileNotFoundException when accessing static resources:

java.io.FileNotFoundException: C:\Program%20Files\Apache%20Software%20Foundation\Tomcat%207.0\webapps\flurfunk\WEB-INF\classes\public\flurfunk.js (Das System kann den angegebenen Pfad nicht finden)
    java.io.FileInputStream.open(Native Method)
    java.io.FileInputStream.<init>(Unknown Source)
    ring.util.servlet$set_body.invoke(servlet.clj:78)
    ring.util.servlet$update_servlet_response.invoke(servlet.clj:108)
    ring.util.servlet$make_service_method$fn__75.invoke(servlet.clj:124)
    flurfunk.servlet$_service.invoke(servlet.clj:1)
    flurfunk.servlet.service(Unknown Source)

Works fine when I install Tomcat into a directory without spaces, e.g. C:\Tomcat7. Also works fine with spaces on Mac, so I guess this issue is Windows-only.

FileNotFoundException: clojure/contrib/prxml.clj

I've got the following exception after launching lein ring server:

Exception in thread "main" java.io.FileNotFoundException: 
Could not locate clojure/contrib/prxml__init.class or clojure/contrib/prxml.clj on classpath:  (war.clj:1)
...
at leiningen.ring$eval72$loading__4414__auto____73.invoke(ring.clj:1)
at leiningen.ring$eval72.invoke(ring.clj:1)
...
at leiningen.ring.war$eval613$loading__4414__auto____614.invoke(war.clj:1)
at leiningen.ring.war$eval613.invoke(war.clj:1)

I've looked at the source and found that leiningen.ring.war indeed uses contrib.prxml, although contrib isn't listed in the project dependencies. It only appears in the ring-core, but as a dev-dependency, so it isn't loaded.

Make it possible to exclude dependencies from uberwar

How about making it possible to exclude dependencies from the WAR generated by lein uberwar?

Our web ring can be build in two ways:

  • WAR suitable for deployment in Tomat
  • JAR that has a main class which launches Jetty

For the JAR, we had to add Jetty as a dependency. The WAR, however, should not include Jetty.

README doesn't indicate how to set development or production mode

README says:

Defaults to true in development mode, false in production

But I could not see anywhere in lein-ring where to set development or production mode. I grepped through the source looking for the words "development" and "production", and didn't find them.

I did however find in jar.clj

                    (assoc-in [:ring :open-browser?] false)
                    (assoc-in [:ring :stacktraces?] false)
                    (assoc-in [:ring :auto-reload?] false))]

Which would indicate that they are all set to false, even though the README says (and testing indicates) some of those options appear to be set somewhere to true by default.

resource-path

normally, the way we interpret resource-path of leiningen to denote files in classpath, but this plugin does not treat them as such and the while creating war, the resource files do not go inside WEB-INF/classes folder. this breaks the code, I had to change the code for our use case. do you see a way to distinguish between web resource and classpath resource

implement :filespecs

The leiningen jar task provides a :filespecs mechanism which allows you to insert arbitrary entries into the jar file. It'd be nice if war and uberwar did the same.

I'm willing to do the work, but can't get to it right now, and want to make sure you're good with copying the project's filespecs into WEB-INF/classes.

Example of it's usage is in the sample.project.clj

lein ring server throws a FileNotFoundException related to Hiccup while lein run works fine

My project.clj:

(defproject ixdictionary "1.0.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[ring/ring-core "1.1.1"]
                 [org.clojure/clojure "1.4.0"]
                 [org.drift-db/drift-db-h2 "1.1.0"]
                 [korma "0.3.0-beta11"]
                 [tnrglobal/bishop "1.0.5"]
                 [cheshire "4.0.0"]
                 [hiccup "1.0.0"]]
  :dev-dependencies [[com.h2database/h2 "1.3.167"]]
  :warn-on-reflection true
  :main ixdictionary.core
  :plugins [[lein-ring "0.7.1"]]
  :ring {:handler ixdictionary.core/ring-handler})

ixdictionary.core/-main just does this: (run-jetty ring-handler {:port 3000})

When I run my app with lein run it starts up just fine.

But when I try lein ring server so I can get auto-code-reloading, I get this:


Exception in thread "main" java.io.FileNotFoundException: Could not locate hiccup/page_helpers__init.class or hiccup/page_helpers.clj on classpath: 
    at clojure.lang.RT.load(RT.java:432)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5227)
    at clojure.core$load_lib.doInvoke(core.clj:5264)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$load_libs.doInvoke(core.clj:5298)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:605)
    at clojure.core$use.doInvoke(core.clj:5392)
    at clojure.lang.RestFn.invoke(RestFn.java:482)
    at ring.middleware.stacktrace$eval88$loading__4784__auto____89.invoke(stacktrace.clj:1)
    at ring.middleware.stacktrace$eval88.invoke(stacktrace.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.eval(Compiler.java:6501)
    at clojure.lang.Compiler.load(Compiler.java:6952)
    at clojure.lang.RT.loadResourceScript(RT.java:359)
    at clojure.lang.RT.loadResourceScript(RT.java:350)
    at clojure.lang.RT.load(RT.java:429)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5227)
    at clojure.core$load_lib.doInvoke(core.clj:5264)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$load_libs.doInvoke(core.clj:5298)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:605)
    at clojure.core$use.doInvoke(core.clj:5392)
    at clojure.lang.RestFn.invoke(RestFn.java:512)
    at ring.server.standalone$eval11$loading__4784__auto____12.invoke(standalone.clj:1)
    at ring.server.standalone$eval11.invoke(standalone.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.eval(Compiler.java:6501)
    at clojure.lang.Compiler.load(Compiler.java:6952)
    at clojure.lang.RT.loadResourceScript(RT.java:359)
    at clojure.lang.RT.loadResourceScript(RT.java:350)
    at clojure.lang.RT.load(RT.java:429)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5227)
    at clojure.core$load_lib.doInvoke(core.clj:5264)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$load_libs.doInvoke(core.clj:5298)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$require.doInvoke(core.clj:5381)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at ring.server.leiningen$eval5$loading__4784__auto____6.invoke(leiningen.clj:1)
    at ring.server.leiningen$eval5.invoke(leiningen.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.eval(Compiler.java:6501)
    at clojure.lang.Compiler.load(Compiler.java:6952)
    at clojure.lang.RT.loadResourceScript(RT.java:359)
    at clojure.lang.RT.loadResourceScript(RT.java:350)
    at clojure.lang.RT.load(RT.java:429)
    at clojure.lang.RT.load(RT.java:400)
    at clojure.core$load$fn__4890.invoke(core.clj:5415)
    at clojure.core$load.doInvoke(core.clj:5414)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5227)
    at clojure.core$load_lib.doInvoke(core.clj:5264)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$load_libs.doInvoke(core.clj:5298)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:603)
    at clojure.core$require.doInvoke(core.clj:5381)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at user$eval1.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6511)
    at clojure.lang.Compiler.eval(Compiler.java:6500)
    at clojure.lang.Compiler.eval(Compiler.java:6477)
    at clojure.core$eval.invoke(core.clj:2797)
    at clojure.main$eval_opt.invoke(main.clj:297)
    at clojure.main$initialize.invoke(main.clj:316)
    at clojure.main$null_opt.invoke(main.clj:349)
    at clojure.main$main.doInvoke(main.clj:427)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:419)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)

It would be great to support multiple servers other than jetty.

I modified lein-ring and ring-server to support http-kit, but it is crude. It would be great to have a plug-able design where the decision of server could be pushed back later in development. In my case it was precipitated by my need of web sockets. Please close this ticket if there is a more appropriate discussion group. I could post to.

Getting stacktrace on `lein ring server`

urbite git:master ❯ uname -a                                                                                         ⏎ ✖ ✱ ◼
Darwin macbook.local 12.0.0 Darwin Kernel Version 12.0.0: Sun Jun 24 23:00:16 PDT 2012; root:xnu-2050.7.9~1/RELEASE_X86_64 x86_64
urbite git:master ❯ java -version                                                                                      ✖ ✱ ◼
java version "1.7.0_06"
Java(TM) SE Runtime Environment (build 1.7.0_06-b24)
Java HotSpot(TM) 64-Bit Server VM (build 23.2-b09, mixed mode)
urbite git:master ❯ clj                                                                                                ✖ ✱ ◼
Clojure 1.4.0
user=> ^C%                                                                                                                   urbite git:master ❯ lein version                                                                                     ⏎ ✖ ✱ ◼
Leiningen 2.0.0-preview8 on Java 1.7.0_06 Java HotSpot(TM) 64-Bit Server VM
urbite git:master ❯ lein ring server                                                                                   ✖ ✱ ◼
2012-08-21 13:35:44.940:INFO:oejs.Server:jetty-7.6.1.v20120215
Started server on port 3000
2012-08-21 13:35:44.984:INFO:oejs.AbstractConnector:Started [email protected]:3000
Exception: java.lang.NullPointerException: null
                                      stacktrace.clj:15 ring.middleware.stacktrace/wrap-stacktrace-log[fn]
                                      stacktrace.clj:79 ring.middleware.stacktrace/wrap-stacktrace-web[fn]
                                          reload.clj:18 ring.middleware.reload/wrap-reload[fn]
                                           jetty.clj:18 ring.adapter.jetty/proxy-handler[fn]
                                       (Unknown Source) ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle
                                HandlerWrapper.java:111 org.eclipse.jetty.server.handler.HandlerWrapper.handle
                                        Server.java:349 org.eclipse.jetty.server.Server.handle
                        AbstractHttpConnection.java:452 org.eclipse.jetty.server.AbstractHttpConnection.handleRequest
                        AbstractHttpConnection.java:884 org.eclipse.jetty.server.AbstractHttpConnection.headerComplete
                        AbstractHttpConnection.java:938 org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete
                                    HttpParser.java:634 org.eclipse.jetty.http.HttpParser.parseNext
                                    HttpParser.java:230 org.eclipse.jetty.http.HttpParser.parseAvailable
                            AsyncHttpConnection.java:76 org.eclipse.jetty.server.AsyncHttpConnection.handle
                         SelectChannelEndPoint.java:609 org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle
                          SelectChannelEndPoint.java:45 org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run
                              QueuedThreadPool.java:599 org.eclipse.jetty.util.thread.QueuedThreadPool.runJob
                              QueuedThreadPool.java:534 org.eclipse.jetty.util.thread.QueuedThreadPool$3.run
                                        Thread.java:722 java.lang.Thread.run

Exception: java.lang.NullPointerException: null
                                      stacktrace.clj:15 ring.middleware.stacktrace/wrap-stacktrace-log[fn]
                                      stacktrace.clj:79 ring.middleware.stacktrace/wrap-stacktrace-web[fn]
                                          reload.clj:18 ring.middleware.reload/wrap-reload[fn]
                                           jetty.clj:18 ring.adapter.jetty/proxy-handler[fn]
                                       (Unknown Source) ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle
                                HandlerWrapper.java:111 org.eclipse.jetty.server.handler.HandlerWrapper.handle
                                        Server.java:349 org.eclipse.jetty.server.Server.handle
                        AbstractHttpConnection.java:452 org.eclipse.jetty.server.AbstractHttpConnection.handleRequest
                        AbstractHttpConnection.java:884 org.eclipse.jetty.server.AbstractHttpConnection.headerComplete
                        AbstractHttpConnection.java:938 org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete
                                    HttpParser.java:634 org.eclipse.jetty.http.HttpParser.parseNext
                                    HttpParser.java:230 org.eclipse.jetty.http.HttpParser.parseAvailable
                            AsyncHttpConnection.java:76 org.eclipse.jetty.server.AsyncHttpConnection.handle
                         SelectChannelEndPoint.java:609 org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle
                          SelectChannelEndPoint.java:45 org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run
                              QueuedThreadPool.java:599 org.eclipse.jetty.util.thread.QueuedThreadPool.runJob
                              QueuedThreadPool.java:534 org.eclipse.jetty.util.thread.QueuedThreadPool$3.run
                                        Thread.java:722 java.lang.Thread.run

The "lein ring server" command wipes my lib directory

I tried installing the latest in my project.clj:

:dev-dependencies [[lein-ring "0.7.1"]]
:ring {:handler server/app
     :init server/bootstrap}

Now when I run "lein ring server", it hangs for a second, then spits out an exception about the Ant JAR missing:

Exception in thread "main" The following error occurred while executing this line:

java.io.FileNotFoundException: <my-project-dir>/lib/dev/ant-1.8.2.jar (No such file or directory) (NO_SOURCE_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)

When I look in my lib directory, all of my JAR files have been removed.

I wasn't using lein-ring before (manually starting a server) and everything was running fine, but I suppose there could be something conflicting elsewhere in my project.clj that's messing with lein-ring. It's the only dev library I use, and other than a bunch of other standard dependencies (ring, compojure), I only have an :aot for an exception class.

I'm using (on OS X Lion):

Leiningen 1.7.0 on Java 1.6.0_31 Java HotSpot(TM) 64-Bit Server VM

Intermittent errors running lein ring server

First off - many thanks for lein-ring @weavejester! Most helpful.

My issue is: I'm building a webservice using Ring and Compojure for SnowPlow and I've been having lots of trouble with intermittent errors when running lein ring server (and lein ring server-headless).

It's happened across different commits, and the error message has varied a couple of times. I'm new to Clojure but I don't think it's a code problem - or if it is, I don't understand how it could be happening intermittently. I shutdown lein ring server with Ctrl-C if that's important.

Anyway, the gist showing the intermittent error happening is here: https://gist.github.com/4001236

And the full source code to my app is here (this is the version causing the intermittent error): https://github.com/snowplow/snowplow/tree/feature/clj-collector/2-collectors/clojure-collector

Any help much appreciated!

no static content served under leiningen 2

When using this project.clj

(defproject cafas "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [ring/ring-core "1.1.1"]
                 [ring/ring-jetty-adapter "1.1.1"]]
  :profiles {
             :dev {:plugins [[lein-swank "1.4.4"]
                             [lein-ring "0.7.1"]]
                   :ring {:handler cafas.core/my-app
                          :auto-reload? true
                          :auto-refresh? true}}})

and this src/cafas/core.clj

(ns cafas.core
  (:use ring.adapter.jetty)
  (:use ring.middleware.resource)
  (:use ring.middleware.file)
  (:use ring.middleware.file-info))

(defn handler [request]
  {:status 200
   :headers {"Content-Type" "text/plain"}
   :body "Hello Another World"})

;; wrap the handler, to be able to add middleware etc
(def my-app (-> #'handler (wrap-file "pages")))

Then, when using leiningen 2 preview 7, when using

lein ring server

All the files in the pages directory are not serving their content, but I get an exception:

java.lang.NullPointerException
Matcher.java:1140   java.util.regex.Matcher.getTextLength
Matcher.java:291    java.util.regex.Matcher.reset
Matcher.java:211    java.util.regex.Matcher.<init>
Pattern.java:888    java.util.regex.Pattern.matcher
core.clj:4286   clojure.core/re-matcher
core.clj:4338   clojure.core/re-find
refresh.clj:18  ring.middleware.refresh/html-content?
refresh.clj:68  ring.middleware.refresh/wrap-with-script[fn]
core.clj:98 compojure.core/routing[fn]
core.clj:2390   clojure.core/some
core.clj:98 compojure.core/routing
RestFn.java:139 clojure.lang.RestFn.applyTo
core.clj:603    clojure.core/apply
core.clj:103    compojure.core/routes[fn]
stacktrace.clj:15   ring.middleware.stacktrace/wrap-stacktrace-log[fn]
stacktrace.clj:79   ring.middleware.stacktrace/wrap-stacktrace-web[fn]
reload.clj:18   ring.middleware.reload/wrap-reload[fn]
jetty.clj:18    ring.adapter.jetty/proxy-handler[fn]
(Unknown Source)    ring.adapter.jetty.proxy$org.eclipse.jetty.server.handler.AbstractHandler$0.handle
HandlerWrapper.java:111 org.eclipse.jetty.server.handler.HandlerWrapper.handle
Server.java:349 org.eclipse.jetty.server.Server.handle
AbstractHttpConnection.java:452 org.eclipse.jetty.server.AbstractHttpConnection.handleRequest
AbstractHttpConnection.java:884 org.eclipse.jetty.server.AbstractHttpConnection.headerComplete
AbstractHttpConnection.java:938 org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete
HttpParser.java:634 org.eclipse.jetty.http.HttpParser.parseNext
HttpParser.java:230 org.eclipse.jetty.http.HttpParser.parseAvailable
AsyncHttpConnection.java:76 org.eclipse.jetty.server.AsyncHttpConnection.handle
SelectChannelEndPoint.java:609  org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle
SelectChannelEndPoint.java:45   org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run
QueuedThreadPool.java:599   org.eclipse.jetty.util.thread.QueuedThreadPool.runJob
QueuedThreadPool.java:534   org.eclipse.jetty.util.thread.QueuedThreadPool$3.run
Thread.java:680 java.lang.Thread.run

When using the file-info middleware I am not getting the exception, but as result the path to the resource. Starting the webapp with the repl works correctly:

user=> (use 'ring.adapter.jetty)                                                                                                          
nil                                                                                                                                                                         
user=> (use 'cafas.core)                                                                                                      
nil                                                                                                                                                                                                                                   
user=> (run-jetty my-app {:port 3000})

Support for multiple rings

Currently you can only define one ring in project.clj:

    :ring {:handler server/handler}

It would be nice to be able to define multiple rings like this:

    :ring [{:handler server/handler} {:handler backend/handler}]

uberjar fails to build when log4j.properties references dependency

(lein ring 0.7.0, Clojure 1.2.1, log4j 1.2.16)

My resources/log4j.properties file references an appender that available in a dependency.

log4j.properties:
log4.rootLogger=INFO,A1, LOGGLY
log4j.appender.LOGGLY=com.roomkey.cloggly.LogglyAppender
...

And in project.clj
{...
:dependencies [...
[com.roomkey/cloggly "1.2"]
...]

...}

Removing LOGGLY from the first line of log4j.properties allows uberjar to work. WIth it in there, uberjar never finishes.

With LOGGLY in place, I can run "lein ring server" and all the other typical leiningen commands without issue. But building an uberjar fails.

Regards,
Chris

lein ring war throws a NullPointerException under leiningen 2

Consider a simple project:

(defproject ex "0.1.0"
  :dependencies [[org.clojure/clojure "1.3.0"]
                 [compojure "1.0.2"]
                 [ring/ring-core "1.0.2"]]
  :plugins [[lein-ring "0.6.4"]]
  :main ex.core
  :ring {:handler ex.core/handler})

With leiningen 2 preview release 3, lein ring war gives the following:

Exception in thread "main" java.lang.NullPointerException
    at java.util.regex.Matcher.getTextLength(Matcher.java:1140)
    at java.util.regex.Matcher.reset(Matcher.java:291)
    at java.util.regex.Matcher.<init>(Matcher.java:211)
    at java.util.regex.Pattern.matcher(Pattern.java:888)
    at clojure.core$re_matcher.invoke(core.clj:4262)
    at clojure.core$re_find.invoke(core.clj:4314)
    at leiningen.core.main$_main$fn__642.invoke(main.clj:142)
    at leiningen.core.main$_main.doInvoke(main.clj:139)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:405)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:518)
    at clojure.core$apply.invoke(core.clj:600)
    at clojure.main$main_opt.invoke(main.clj:323)
    at clojure.main$main.doInvoke(main.clj:426)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at clojure.lang.Var.invoke(Var.java:413)
    at clojure.lang.AFn.applyToHelper(AFn.java:172)
    at clojure.lang.Var.applyTo(Var.java:518)
    at clojure.main.main(main.java:37)

Option to include test classpath as well as main classpath

Occasionally, it is useful to include the test classpath when executing "lein ring server". In my particular case, I'm developing a web toolkit and want to be able to run a test application built in the toolkit. Ideally, the namespaces defining the test application would be in my test folder, but currently I'm forced to put them in my src folder (which also means they'll be distributed in my jar file).

Maybe "lein ring test-server" ... or an option inside project.clj.

Should be possible to use the custom web.xml for lein-ring-server

It was unexpected that this was not the case, so in our case I had to add back code to our project to launch jetty and load the desired web.xml, like so:

(defn webapp-handler []
  (doto (WebAppContext.)
    (.setDescriptor (str (clojure.java.io/resource "WEB-INF/web.xml")))
    (.setContextPath "/")
    (.setResourceBase (str (clojure.java.io/resource "WEB-INF/")))
    (.setParentLoaderPriority true)))

(defn run-jetty
  "Modified from ring implementation to expect a jetty handler instead of a ring handler"
  [handler options]
  (let [s (#'jetty/create-server
           (dissoc options :configurator))]
    (doto s
      (.setHandler handler)
      (.setThreadPool (QueuedThreadPool. (options :max-threads 50))))
    (when-let [configurator (:configurator options)]
      (configurator s))
    (.start s)
    (when (:join? options true)
      (.join s))
    s))

Is this within the scope of lein-ring-server?

Could not locate ring/util/servlet__init.class or ring/util/servlet.clj on classpath

When building a WAR with "lein ring uberwar" and if ring-servlet is only in the lib/dev directory but not in the lib directory, ring-servlet is not added to the WAR.

When deploying the WAR, for instance on Jetty, one get the following error:

"Could not locate ring/util/servlet__init.class or ring/util/servlet.clj on classpath".

A temporary work around is to explicitly adds [ring/ring-servlet "1.0.1"] to the list of dependencies in the project.clj.

lein-ring 0.8.1 does not support clojure-1.5-RC1

project.clj:

    :dependencies [[org.clojure/clojure "1.5.0-RC1"] ...
    :plugins 
      [[lein-ring "0.8.1"]
        ...

$ lein ring server

    Exception in thread "main" java.lang.IllegalArgumentException: contains? not supported on type: clojure.lang.LazySeq
    at clojure.lang.RT.contains(RT.java:715)
    at clojure.core$contains_QMARK_.invoke(core.clj:1402)
    at ns_tracker.dependency$depends_QMARK_.invoke(dependency.clj:38)
    at ns_tracker.dependency$depend.invoke(dependency.clj:53)
    at ns_tracker.dependency$depend$fn__820.invoke(dependency.clj:58)
    at clojure.core.protocols$fn__6070.invoke(protocols.clj:143)
    at clojure.core.protocols$fn__6041$G__6036__6050.invoke(protocols.clj:19)
    at clojure.core.protocols$fn__6070.invoke(protocols.clj:147)
    at clojure.core.protocols$fn__6041$G__6036__6050.invoke(protocols.clj:19)
    at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
    at clojure.core.protocols$fn__6064.invoke(protocols.clj:48)
    at clojure.core.protocols$fn__6015$G__6010__6028.invoke(protocols.clj:13)
    at clojure.core$reduce.invoke(core.clj:6149)
    at ns_tracker.dependency$depend.doInvoke(dependency.clj:59)
    at clojure.lang.RestFn.applyTo(RestFn.java:146)
    at clojure.core$apply.invoke(core.clj:621)
    at ns_tracker.core$add_to_dep_graph$fn__939.invoke(core.clj:27)
    at clojure.core.protocols$fn__6070.invoke(protocols.clj:143)
    at clojure.core.protocols$fn__6041$G__6036__6050.invoke(protocols.clj:19)
    at clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)
    at clojure.core.protocols$fn__6062.invoke(protocols.clj:54)
    at clojure.core.protocols$fn__6015$G__6010__6028.invoke(protocols.clj:13)
    at clojure.core$reduce.invoke(core.clj:6149)
    at ns_tracker.core$add_to_dep_graph.invoke(core.clj:24)
    at ns_tracker.core$update_dependency_graph.invoke(core.clj:35)
    at ns_tracker.core$ns_tracker.invoke(core.clj:64)
    at ns_tracker.core$ns_tracker.invoke(core.clj:58)
    at ring.middleware.reload$wrap_reload.doInvoke(reload.clj:14)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at ring.server.standalone$add_auto_reload.invoke(standalone.clj:60)
    at ring.server.standalone$add_middleware.invoke(standalone.clj:70)
    at ring.server.standalone$serve.doInvoke(standalone.clj:90)
    at clojure.lang.RestFn.invoke(RestFn.java:423)
    at ring.server.leiningen$serve.invoke(leiningen.clj:20)
    at user$eval4799.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6618)
    at clojure.lang.Compiler.eval(Compiler.java:6608)
    at clojure.lang.Compiler.eval(Compiler.java:6581)
    at clojure.core$eval.invoke(core.clj:2852)
    at clojure.main$eval_opt.invoke(main.clj:300)
    at clojure.main$initialize.invoke(main.clj:319)
    at clojure.main$null_opt.invoke(main.clj:354)
    at clojure.main$main$fn__6676.invoke(main.clj:432)
    at clojure.main$main.doInvoke(main.clj:429)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:419)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)

note : lein-ring 0.8.0 not have this problem

Can't get code autoloading

I start my server using:

lein ring server

But when I change my code eg. in server.clj and reload the browser the new code isn't loaded in.

My handler in server.clj looks like:

(def handler
  (-> app-routes
    (file/wrap-file "public")
    (file-info/wrap-file-info)
    (log/wrap-log)
    (params/wrap-params)
    (keyword-params/wrap-keyword-params)
    (nested-params/wrap-nested-params)))

And my project.clj:

:plugins [[lein-ring "0.7.5"]
                [lein-cljsbuild "0.2.7"]]
:ring {:handler app.server/handler
          :auto-reload? true
          :auto-refresh true}

Any idea why it isn't working?

text/plain instead text/html from uberwar

I have a simple application which behaves normally when run with 'lein ring server-headless'. If I build a war with 'lein ring uberwar' and deploy it under tomcat, html pages are returned with text/plain content type. The same tomcat instance runs other wars generated by 'lein uberwar' without problems. The application is https://github.com/kolov/civi-stripped

indirect dep of [thneed "1.0.0-SNAPSHOT"] is annoying

lein-ring depends on leinjacker depends on trammel depends on a thneed snapshot, so anybody using lein-ring gets mildly annoying snapshot download messages from lein every day or so.

At a glance, it looks like lein-ring depends on an old version of leinjacker, while newer versions don't depend on trammel and so wouldn't have the issue anymore. Therefore presumably if lein-ring updated its dependency on leinjacker this would go away.

run-server task violates process isolation

As mentioned in #27, the server task currently violates the Leiningen/project process isolation, which was allowed on Leiningen 1 but not 2. Rather than requiring leiningen.ring.run-server, it should build up a form that it can pass to eval-in-project.

changing template requires restart

I'm using the lein-ring plugin during development automatically reloads changes to source files without requiring a restart. However changes to the templates are cached and require a restart which lengthens the development feedback cycle. Would it be possible to check if reloading is enabled or provide an option to disable caching behavior in development?

Complain when the function specified in :init does not exist

If you provide this in your project.clj:

{:init project.handler/fn-which-does-not-exist
  :handler project.handler/app }

lein ring server will not complain. This makes for an annoying troubleshooting experience in the event that the init function is misspelled.

Support multiple war-resources-paths

We currently support multiple resource-paths by doing (concat (:resources-path project)). We support the same for source-paths. It would be super useful to also support multiple war-resources-paths in the same way (so that multiple activated profiles can bring in different sets of war-resources composably).

My use case currently is that I have one set of war-resources that need to be brought in conditionally based on a profile-activated choice of authentication strategy (legacy J2EE authentication or not), and one set that needs to be brought in based on choice of JBoss version. Right now I've got to maintain m*n sets of resources where I could be maintaining m+n with this option.

0.8.3 runs all tests on reload

The 0.8.3 change seems to cause our tests to run whenever a reload happens.

i.e. If we run "lein ring server" the app loads happily (without running tests)
If we then change a source file and refresh the browser, the server reloads and runs all our test code.

Reverting to 0.8.2 made this behaviour go away.

we have not set :reload-paths or changed our default :source-paths settings - our sources are in the "src" directory, tests are in "test" (and are Midje tests, btw)

Work as a plugin

Is it possible to have lein-ring work as a leiningen plugin instead of being an explicit dev dependency in project.clj?

Using a custom web.xml file

Is there any way right now to build an uberwar using a custom web.xml file rather than an auto-generated one?

My use case is that I'd like to integrate ehcache into my project - which requires a separate ehcache.xml file and particular stanzas to be set up in web.xml.

throws a duplicate entry ZipException

Executing war or uberwar on my Mac now throws a duplicate entry ZipException. This is caused by the .DS_Sore file in each directory on my MAC. Same kind of problem would happen if you were using svn. I have fixed this locally with the following change in war.clj.

(defn skip-file? [project war-path file](or %28re-find #"^.?#" %28.getName file%29%29
%28re-find #"~$" %28.getName file%29%29
%28re-find #".DS_Store" %28.getName file%29%29
%28some #%28re-find % war-path%29
%28get-in project [:ring :war-exclusions]%29%29))

war command is slow

Hi,

I've noticed that the command below takes a long time to finish (lein ring jar takes ~7 seconds while lein ring war takes a minute). I'm not that into clojure compilation internals but is there any explanation of this taking this much time? Is it possible to have a shortcut?

/usr/bin/java -classpath /tank/proger/dev/myproject/test:/tank/proger/dev/myproject/src:/tank/proger/dev/myproject/resources:/tank/proger/dev/myproject/target/classes:/tank/proger/.m2/repository/ring/ring-core/1.2.0-beta2/ring-core-1.2.0-beta2.jar:/tank/proger/.m2/repository/org/clojure/java.classpath/0.2.0/java.classpath-0.2.0.jar:/tank/proger/.m2/repository/org/eclipse/jetty/jetty-io/7.6.8.v20121106/jetty-io-7.6.8.v20121106.jar:/tank/proger/.m2/repository/clj-stacktrace/clj-stacktrace/0.2.5/clj-stacktrace-0.2.5.jar:/tank/proger/.m2/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar:/tank/proger/.m2/repository/ring/ring-jetty-adapter/1.2.0-beta2/ring-jetty-adapter-1.2.0-beta2.jar:/tank/proger/.m2/repository/ns-tracker/ns-tracker/0.2.1/ns-tracker-0.2.1.jar:/tank/proger/.m2/repository/org/eclipse/jetty/orbit/javax.servlet/2.5.0.v201103041518/javax.servlet-2.5.0.v201103041518.jar:/tank/proger/.m2/repository/org/eclipse/jetty/jetty-continuation/7.6.8.v20121106/jetty-continuation-7.6.8.v20121106.jar:/tank/proger/.m2/repository/ring/ring-codec/1.0.0/ring-codec-1.0.0.jar:/tank/proger/.m2/repository/clout/clout/1.0.1/clout-1.0.1.jar:/tank/proger/.m2/repository/org/clojure/tools.reader/0.7.3/tools.reader-0.7.3.jar:/tank/proger/.m2/repository/org/clojure/core.incubator/0.1.0/core.incubator-0.1.0.jar:/tank/proger/.m2/repository/ring/ring-servlet/1.2.0-beta2-SNAPSHOT/ring-servlet-1.2.0-beta2-SNAPSHOT.jar:/tank/proger/.m2/repository/digest/digest/1.3.0/digest-1.3.0.jar:/tank/proger/.m2/repository/org/clojure/tools.macro/0.1.0/tools.macro-0.1.0.jar:/tank/proger/.m2/repository/clj-time/clj-time/0.4.4/clj-time-0.4.4.jar:/tank/proger/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar:/tank/proger/.m2/repository/org/clojure/clojure/1.5.1/clojure-1.5.1.jar:/tank/proger/.m2/repository/hiccup/hiccup/1.0.3/hiccup-1.0.3.jar:/tank/proger/.m2/repository/commons-codec/commons-codec/1.6/commons-codec-1.6.jar:/tank/proger/.m2/repository/compojure/compojure/1.1.5/compojure-1.1.5.jar:/tank/proger/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar:/tank/proger/.m2/repository/ring/ring/1.2.0-beta2/ring-1.2.0-beta2.jar:/tank/proger/.m2/repository/org/clojure/tools.nrepl/0.2.2/tools.nrepl-0.2.2.jar:/tank/proger/.m2/repository/org/eclipse/jetty/jetty-http/7.6.8.v20121106/jetty-http-7.6.8.v20121106.jar:/tank/proger/.m2/repository/org/clojure/tools.namespace/0.1.3/tools.namespace-0.1.3.jar:/tank/proger/.m2/repository/org/eclipse/jetty/jetty-util/7.6.8.v20121106/jetty-util-7.6.8.v20121106.jar:/tank/proger/.m2/repository/ring/ring-devel/1.2.0-beta2/ring-devel-1.2.0-beta2.jar:/tank/proger/.m2/repository/commons-fileupload/commons-fileupload/1.2.2/commons-fileupload-1.2.2.jar:/tank/proger/.m2/repository/org/eclipse/jetty/jetty-server/7.6.8.v20121106/jetty-server-7.6.8.v20121106.jar \ -Dclojure.compile.path=/tank/proger/dev/myproject/target/classes \ -Dmyproject.version=0.1.0-SNAPSHOT \ -Dfile.encoding=UTF-8 \ -Dclojure.debug=false \ clojure.main \ -e '(do (set! _warn-on-reflection_ nil) nil (do (clojure.core/compile (quote myproject.servlet)) nil))'

`lein ring war` throws NPE

I have a project that I have been working on and testing locally using lein ring server, occasionally I will run lein ring jar. I went to deploy to AWS Beanstalk today and the beanstalk plugin was throwing an NPE. I tracked it down to lein ring war.

Any help identifying the cause of this issue would be really appreciated. My project configuration is at the bottom of this issue.

➜  api-clj git:(master) ✗ lein ring jar
Created /Users/eric/src/api-clj/target/provided/api-clj-0.1-SNAPSHOT.jar
➜  api-clj git:(master) ✗ lein ring war
WARNING: read already refers to: #'clojure.core/read in namespace: api-clj.model.products, being replaced by: #'api-clj.model.products/read
Exception in thread "main" java.lang.NullPointerException, compiling:(handler.clj:1:1)
    at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3463)
    at clojure.lang.Compiler.compile1(Compiler.java:7153)
    at clojure.lang.Compiler.compile1(Compiler.java:7143)
    at clojure.lang.Compiler.compile(Compiler.java:7219)
    at clojure.lang.RT.compile(RT.java:398)
    at clojure.lang.RT.load(RT.java:438)
    at clojure.lang.RT.load(RT.java:411)
    at clojure.core$load$fn__5018.invoke(core.clj:5530)
    at clojure.core$load.doInvoke(core.clj:5529)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5336)
    at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
    at clojure.core$load_lib.doInvoke(core.clj:5374)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:619)
    at clojure.core$load_libs.doInvoke(core.clj:5413)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:619)
    at clojure.core$require.doInvoke(core.clj:5496)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at api_clj.servlet$loading__4910__auto__.invoke(servlet.clj:1)
    at clojure.lang.AFn.applyToHelper(AFn.java:159)
    at clojure.lang.AFn.applyTo(AFn.java:151)
    at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3458)
    at clojure.lang.Compiler.compile1(Compiler.java:7153)
    at clojure.lang.Compiler.compile1(Compiler.java:7143)
    at clojure.lang.Compiler.compile1(Compiler.java:7143)
    at clojure.lang.Compiler.compile(Compiler.java:7219)
    at clojure.lang.RT.compile(RT.java:398)
    at clojure.lang.RT.load(RT.java:438)
    at clojure.lang.RT.load(RT.java:411)
    at clojure.core$load$fn__5018.invoke(core.clj:5530)
    at clojure.core$load.doInvoke(core.clj:5529)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5336)
    at clojure.core$compile$fn__5023.invoke(core.clj:5541)
    at clojure.core$compile.invoke(core.clj:5540)
    at user$eval7.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6619)
    at clojure.lang.Compiler.eval(Compiler.java:6608)
    at clojure.lang.Compiler.eval(Compiler.java:6609)
    at clojure.lang.Compiler.eval(Compiler.java:6582)
    at clojure.core$eval.invoke(core.clj:2852)
    at clojure.main$eval_opt.invoke(main.clj:308)
    at clojure.main$initialize.invoke(main.clj:327)
    at clojure.main$null_opt.invoke(main.clj:362)
    at clojure.main$main.doInvoke(main.clj:440)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:419)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:532)
    at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
    at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4858)
    at clojure.lang.Compiler$DefExpr.emit(Compiler.java:428)
    at clojure.lang.Compiler.compile1(Compiler.java:7152)
    at clojure.lang.Compiler.compile(Compiler.java:7219)
    at clojure.lang.RT.compile(RT.java:398)
    at clojure.lang.RT.load(RT.java:438)
    at clojure.lang.RT.load(RT.java:411)
    at clojure.core$load$fn__5018.invoke(core.clj:5530)
    at clojure.core$load.doInvoke(core.clj:5529)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5336)
    at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
    at clojure.core$load_lib.doInvoke(core.clj:5374)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:619)
    at clojure.core$load_libs.doInvoke(core.clj:5413)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:619)
    at clojure.core$require.doInvoke(core.clj:5496)
    at clojure.lang.RestFn.invoke(RestFn.java:482)
    at api_clj.handler$loading__4910__auto__.invoke(handler.clj:1)
    at clojure.lang.AFn.applyToHelper(AFn.java:159)
    at clojure.lang.AFn.applyTo(AFn.java:151)
    at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3458)
    ... 51 more
Subprocess failed

project.clj

(defproject api-clj "0.1-SNAPSHOT"

  :global-vars {*warn-on-reflection* true
                     *assert* false}

  :plugins [[lein-ring "0.8.5"]
               [lein-beanstalk "0.2.7"]]

  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/core.incubator "0.1.2"]
                 [compojure "1.1.5"]
                 [ring/ring-json "0.2.0"]
                 [ring-cors "0.1.0"]
                 [bouncer "0.2.3-beta2"]
                 [cascalog/carbonite "1.3.0"]
                 [clojurewerkz/scrypt "1.0.0"]
                 [org.clojure/java.jdbc "0.3.0-alpha4"]
                 [mysql/mysql-connector-java "5.1.25"]]

  ;; these eclusions ensure that AWS SDK logging goes through SLF4J -> Logback
  :exclusions [commons-logging
               org.slf4j/slf4j-nop
               org.slf4j/slf4j-log4j12
               log4j]

  :ring {:handler api-clj.handler/api}

  :profiles {:dev {:dependencies [[ring-mock "0.1.4"]]}})

uberwar needs to ignore .svn

When creating a uberwar from a project verson controlled by subversion, the .svn files are not ignored, this will results in duplicated entry error. A similar problem for lein uberjar was reported and fixed, see technomancy/leiningen#208, please do the same for lein-ring. Thanks a lot.

java.io.FileNotFoundException proxy%24javax Tomcat

Using lein-ring 0.4.5, I've created a basic servlet. And after:

lein ring uberwar

And then copying the war into my Tomcat 7 web apps directory. I get the following on startup:

Aug 25, 2011 9:58:19 AM org.apache.catalina.startup.ContextConfig processAnnotationsJndi
SEVERE: Unable to process JNDI URL [jndi:/localhost/my-server-0.1.0-standalone/WEB-INF/classes/ring/util/servlet/proxy%24javax] for annotations
java.io.FileNotFoundException: jndi:/localhost/my-server-0.1.0-standalone/WEB-INF/classes/ring/util/servlet/proxy%24javax
at org.apache.naming.resources.DirContextURLConnection.list(DirContextURLConnection.java:457)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJndi(ContextConfig.java:1901)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJndi(ContextConfig.java:1905)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJndi(ContextConfig.java:1905)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJndi(ContextConfig.java:1905)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJndi(ContextConfig.java:1905)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1828)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1295)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:896)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:322)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:607)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:932)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:529)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1377)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1436)
at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:334)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:211)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:187)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:582)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:300)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)

java.lang.AssertionError with latest Leiningen

Looks like lein-ring 0.7.5 and 0.8.0-SNAPSHOT aren't compatible with the latest master version of Leiningen 2:

$ lein ring server-headless
Exception in thread "main" java.lang.AssertionError: Assert failed: (vector? (:dependencies project []))
at leinjacker.deps$add_if_missing.invoke(deps.clj:43)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.AFn.applyTo(AFn.java:151)
at clojure.core$apply.invoke(core.clj:603)
at leiningen.ring.util$update_project.doInvoke(util.clj:46)

Not sure if the problem is with leinjacker or Leiningen?

With a Bishop project, changed source files are not being reloaded

I wasn’t sure whether to file this here or in the Bishop project.

My main handler is defined in my namespace ixdictionary.core like so:

;; this is a var so it can be used by lein-ring
(def ring-handler (-> (bishop/handler routes)
                      (wrap-params)
                      (wrap-multipart-params)))

and my project.clj includes these keys:

  :plugins [[lein-ring "0.7.1"]]
  :ring {:handler ixdictionary.core/ring-handler}

I’m using Ring 1.1.1 and Leiningen 1.7.1 on Java 1.6.0_33.

My project also specifies Clojure 1.4.0, if that’s important.

When I run my app with lein ring server, it runs fine, but when I change the source code for my resources, it doesn’t appear to be reloaded.

Always AOT-compiles my whole project

When I do lein ring server, I see "Compiling myapp.main" and then a very long pause while my entire app and all libraries are AOTed. There is no :gen-class in this namespace, and no need for lein-ring to create an uberwar or anything, so I can't see why anything needs to be AOTed. The slowness is a huge problem, of course, and additionally it leaves around tons of old classfiles, so that if I check out a different git branch with different dependencies, I get conflicts when the old classfiles are used against the new dependencies (at least I think that's what's going on). I have to lein clean and then AOT the whole thing again, wasting many minutes.

My project.clj contains:

  :ring {:handler myapp.main/handler
         :port 9255
         :open-browser? false
         :init myapp.main/init
         :destroy myapp.main/destroy
         :web-xml "web.xml"}

Is this a known bug in lein-ring? A feature that for some reason I should learn to love? Something that I can easily turn off?

java.io.FileNotFoundException: http://localhost:3000

Such unlucky day - everything is breaking! :)

I've got following exception after running lein ring server:

Started server on port 3000
2012-01-17 11:44:13.896:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
2012-01-17 11:44:13.898:INFO::jetty-6.1.25
2012-01-17 11:44:13.971:INFO::Started [email protected]:3000
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: http://localhost:3000
    at clojure.lang.Util.runtimeException(Util.java:165)
    at clojure.lang.Reflector.invokeConstructor(Reflector.java:193)
    at clojure.java.browse_ui$open_url_in_swing.invoke(browse_ui.clj:15)
    at clojure.lang.Var.invoke(Var.java:401)
    at clojure.java.browse$open_url_in_swing.invoke(browse.clj:44)
    at clojure.java.browse$browse_url.invoke(browse.clj:52)
    at leiningen.ring.run_server$open_browser.invoke(run_server.clj:55)
    at leiningen.ring.run_server$run_server.invoke(run_server.clj:60)
    at user$eval2003.invoke(NO_SOURCE_FILE:1)
    at clojure.lang.Compiler.eval(Compiler.java:6465)
    at clojure.lang.Compiler.eval(Compiler.java:6455)
    at clojure.lang.Compiler.eval(Compiler.java:6431)
    at clojure.core$eval.invoke(core.clj:2795)
    at clojure.main$eval_opt.invoke(main.clj:296)
    at clojure.main$initialize.invoke(main.clj:315)
    at clojure.main$null_opt.invoke(main.clj:348)
    at clojure.main$main.doInvoke(main.clj:426)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:405)
    at clojure.lang.AFn.applyToHelper(AFn.java:163)
    at clojure.lang.Var.applyTo(Var.java:518)
    at clojure.main.main(main.java:37)
Caused by: java.io.FileNotFoundException: http://localhost:3000
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1458)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1452)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1106)
    at javax.swing.JEditorPane.getStream(JEditorPane.java:827)
    at javax.swing.JEditorPane.setPage(JEditorPane.java:433)
    at javax.swing.JEditorPane.setPage(JEditorPane.java:939)
    at javax.swing.JEditorPane.<init>(JEditorPane.java:273)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at clojure.lang.Reflector.invokeConstructor(Reflector.java:183)
    ... 20 more
Caused by: java.io.FileNotFoundException: http://localhost:3000
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1401)
    at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:397)
    at javax.swing.JEditorPane.getStream(JEditorPane.java:792)
    ... 28 more

Probably it's a clojure.java.browse problem, but I leave this report here as a reminder until it'll be fixed (if you don't mind).

Issue on clojure jira: http://dev.clojure.org/jira/browse/CLJ-912

seq-union does not exist

When I update lein-ring past 6180c4e, I get the following error when I try to start a server via lein ring server-headless:

Exception in thread "main" java.lang.IllegalAccessError: seq-union does not exist
    at clojure.core$refer.doInvoke(core.clj:3849)
    at clojure.lang.RestFn.applyTo(RestFn.java:139)
    at clojure.core$apply.invoke(core.clj:619)
    at clojure.core$load_lib.doInvoke(core.clj:5394)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:619)
    at clojure.core$load_libs.doInvoke(core.clj:5413)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:621)
    at clojure.core$use.doInvoke(core.clj:5507)
    at clojure.lang.RestFn.invoke(RestFn.java:457)
    at clojure.lang.RT.load(RT.java:411)
    at clojure.core$load$fn__5018.invoke(core.clj:5530)
    at clojure.core$load.doInvoke(core.clj:5529)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invoke(core.clj:5336)
    at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
    at clojure.core$load_lib.doInvoke(core.clj:5374)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invoke(core.clj:619)
    at clojure.core$load_libs.doInvoke(core.clj:5413)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invoke(core.clj:621)
    at clojure.core$use.doInvoke(core.clj:5507)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at ring.middleware.reload$eval17$loading__4910__auto____18.invoke(reload.clj:1)
    at ring.middleware.reload$eval17.invoke(reload.clj:1)
    ...

I get the same effect if I manually specify the same ring-server version in my project.clj (expected).

I can see that this is eventually coming from ns-tracker (used by ring.reload in the new version of ring, which is used by the new version of ring-server) and am thinking there might be a mismatched dependency somewhere. Any idea what's going on? What's the best way of troubleshooting this for a plugin dependency tree (as opposed to something I can see with lein deps :tree)?

Thanks!

When making a project with periods in the folder name, project is not created properly and lein ring fails

When making a project with periods in the folder name, lein ring subprocess fails

I was told this is a Lein-Ring issue, as seen here:
technomancy/leiningen#1161


when running a new lein project, compojure, and running ring server I get an error on the project folder (lb.juncoapps.com):

Exception in thread "main" java.io.FileNotFoundException: Could not locate lb/juncoapps/com/handler__init.class or lb/juncoapps/com/handler.clj on classpath:
at clojure.lang.RT.load(RT.java:443)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
at clojure.core$load_lib.doInvoke(core.clj:5374)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$load_libs.doInvoke(core.clj:5413)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$require.doInvoke(core.clj:5496)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at user$eval3.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6608)
at clojure.lang.Compiler.eval(Compiler.java:6582)
at clojure.core$eval.invoke(core.clj:2852)
at clojure.main$eval_opt.invoke(main.clj:308)
at clojure.main$initialize.invoke(main.clj:327)
at clojure.main$null_opt.invoke(main.clj:362)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
Subprocess failed

is there a way around this other than renaming the folder?
if this is already an issue being tracked, please let me know and I'll remove this.

Steps to produce error:

  1. lein new compojure lb.juncoapps.com
  2. cd lb.juncoapps.com/
  3. lein ring server

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.