title: How to include properties with Lein-Ring uberwar
body: <p>We're trying to do a test deploy of our Leiningen project on JBoss using the <code>lein ring uberwar</code> command. I was having great success with this until I tried to read a properties file.</p>
  
  <p>I have a function that reads a properties file into a map:</p>
  
  <pre><code>(defn load-properties
    [file-name]
    (with-open [^java.io.Reader reader (io/reader file-name)]
      (let [properties (java.util.Properties.)]
        (.load properties reader)
        (into {} (for [[k v] properties] [(keyword k) (read-string v)])))))
  </code></pre>
  
  <p>And I use it like this:</p>
  
  <pre><code>(def settings (load-properties "application.properties"))
  </code></pre>
  
  <p>"application.properties" is the name of a file in my project directory. Everything works great with <code>lein run</code>, but when I create the standalone war and cp it to JBoss, this is the stack trace:</p>
  
  <pre><code>16:51:08,140 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/kente].[kente.core/application servlet]] (http-/127.0.0.1:8080-1) Allocate exception for ser
  vlet kente.core/application servlet: java.io.FileNotFoundException: application.properties (The system cannot find the file specified)
          at java.io.FileInputStream.open(Native Method) [rt.jar:1.6.0_37]
          at java.io.FileInputStream.&lt;init&gt;(Unknown Source) [rt.jar:1.6.0_37]
          at clojure.java.io$fn__8326.invoke(io.clj:233) [clojure-1.4.0.jar:]
          at clojure.java.io$fn__8265$G__8230__8272.invoke(io.clj:73) [clojure-1.4.0.jar:]
          at clojure.java.io$fn__8338.invoke(io.clj:262) [clojure-1.4.0.jar:]
          at clojure.java.io$fn__8265$G__8230__8272.invoke(io.clj:73) [clojure-1.4.0.jar:]
          at clojure.java.io$fn__8300.invoke(io.clj:169) [clojure-1.4.0.jar:]
          at clojure.java.io$fn__8239$G__8234__8246.invoke(io.clj:73) [clojure-1.4.0.jar:]
          at clojure.java.io$reader.doInvoke(io.clj:106) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.invoke(RestFn.java:410) [clojure-1.4.0.jar:]
          at kente.utils$load_properties.invoke(utils.clj:7) [classes:]
          at clojure.lang.AFn.applyToHelper(AFn.java:161) [clojure-1.4.0.jar:]
          at clojure.lang.AFn.applyTo(AFn.java:151) [clojure-1.4.0.jar:]
          at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3382) [clojure-1.4.0.jar:]
          at clojure.lang.Compiler$DefExpr.eval(Compiler.java:398) [clojure-1.4.0.jar:]
          at clojure.lang.Compiler.eval(Compiler.java:6516) [clojure-1.4.0.jar:]
          at clojure.lang.Compiler.load(Compiler.java:6952) [clojure-1.4.0.jar:]
          at clojure.lang.RT.loadResourceScript(RT.java:359) [clojure-1.4.0.jar:]
          at clojure.lang.RT.loadResourceScript(RT.java:350) [clojure-1.4.0.jar:]
          at clojure.lang.RT.load(RT.java:429) [clojure-1.4.0.jar:]
          at clojure.lang.RT.load(RT.java:400) [clojure-1.4.0.jar:]
          at clojure.core$load$fn__4890.invoke(core.clj:5415) [clojure-1.4.0.jar:]
          at clojure.core$load.doInvoke(core.clj:5414) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.invoke(RestFn.java:408) [clojure-1.4.0.jar:]
          at clojure.core$load_one.invoke(core.clj:5227) [clojure-1.4.0.jar:]
          at clojure.core$load_lib.doInvoke(core.clj:5264) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.applyTo(RestFn.java:142) [clojure-1.4.0.jar:]
          at clojure.core$apply.invoke(core.clj:603) [clojure-1.4.0.jar:]
          at clojure.core$load_libs.doInvoke(core.clj:5298) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.applyTo(RestFn.java:137) [clojure-1.4.0.jar:]
          at clojure.core$apply.invoke(core.clj:605) [clojure-1.4.0.jar:]
          at clojure.core$use.doInvoke(core.clj:5392) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.invoke(RestFn.java:421) [clojure-1.4.0.jar:]
          at kente.core$eval9$loading__4784__auto____10.invoke(core.clj:1)
          at kente.core$eval9.invoke(core.clj:1)
          at clojure.lang.Compiler.eval(Compiler.java:6511) [clojure-1.4.0.jar:]
          at clojure.lang.Compiler.eval(Compiler.java:6501) [clojure-1.4.0.jar:]
          at clojure.lang.Compiler.load(Compiler.java:6952) [clojure-1.4.0.jar:]
          at clojure.lang.RT.loadResourceScript(RT.java:359) [clojure-1.4.0.jar:]
          at clojure.lang.RT.loadResourceScript(RT.java:350) [clojure-1.4.0.jar:]
          at clojure.lang.RT.load(RT.java:429) [clojure-1.4.0.jar:]
          at clojure.lang.RT.load(RT.java:400) [clojure-1.4.0.jar:]
          at clojure.core$load$fn__4890.invoke(core.clj:5415) [clojure-1.4.0.jar:]
          at clojure.core$load.doInvoke(core.clj:5414) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.invoke(RestFn.java:408) [clojure-1.4.0.jar:]
          at clojure.core$load_one.invoke(core.clj:5227) [clojure-1.4.0.jar:]
          at clojure.core$load_lib.doInvoke(core.clj:5264) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.applyTo(RestFn.java:142) [clojure-1.4.0.jar:]
          at clojure.core$apply.invoke(core.clj:603) [clojure-1.4.0.jar:]
          at clojure.core$load_libs.doInvoke(core.clj:5298) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.applyTo(RestFn.java:137) [clojure-1.4.0.jar:]
          at clojure.core$apply.invoke(core.clj:603) [clojure-1.4.0.jar:]
          at clojure.core$require.doInvoke(core.clj:5381) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.invoke(RestFn.java:421) [clojure-1.4.0.jar:]
          at kente.servlet$eval3$loading__4784__auto____4.invoke(servlet.clj:1)
          at kente.servlet$eval3.invoke(servlet.clj:1)
          at clojure.lang.Compiler.eval(Compiler.java:6511) [clojure-1.4.0.jar:]
          at clojure.lang.Compiler.eval(Compiler.java:6501) [clojure-1.4.0.jar:]
          at clojure.lang.Compiler.eval(Compiler.java:6500) [clojure-1.4.0.jar:]
          at clojure.lang.Compiler.load(Compiler.java:6952) [clojure-1.4.0.jar:]
          at clojure.lang.RT.loadResourceScript(RT.java:359) [clojure-1.4.0.jar:]
          at clojure.lang.RT.loadResourceScript(RT.java:350) [clojure-1.4.0.jar:]
          at clojure.lang.RT.load(RT.java:429) [clojure-1.4.0.jar:]
          at clojure.lang.RT.load(RT.java:400) [clojure-1.4.0.jar:]
          at clojure.core$load$fn__4890.invoke(core.clj:5415) [clojure-1.4.0.jar:]
          at clojure.core$load.doInvoke(core.clj:5414) [clojure-1.4.0.jar:]
          at clojure.lang.RestFn.invoke(RestFn.java:408) [clojure-1.4.0.jar:]
          at clojure.lang.Var.invoke(Var.java:415) [clojure-1.4.0.jar:]
          at kente.servlet.&lt;clinit&gt;(Unknown Source) [classes:]
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_37]
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.6.0_37]
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.6.0_37]
          at java.lang.reflect.Constructor.newInstance(Unknown Source) [rt.jar:1.6.0_37]
          at org.jboss.msc.value.ConstructedValue.getValue(ConstructedValue.java:61)
          at org.jboss.as.naming.ValueManagedReferenceFactory.getReference(ValueManagedReferenceFactory.java:49)
          at org.jboss.as.ee.component.ManagedReferenceInterceptorFactory$ManagedReferenceInterceptor.processInvocation(ManagedReferenceInterceptorFactory.java:90) [jboss-as-ee-7.1.3
  .Final-redhat-4.jar:7.1.3.Final-redhat-4]
          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
          at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
          at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
          at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
          at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.1.Final-redhat-2.jar:1.1.1.Final-redhat-2]
          at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161) [jboss-as-ee-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
          at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:85) [jboss-as-ee-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
          at org.jboss.as.web.deployment.component.WebComponentInstantiator$1.&lt;init&gt;(WebComponentInstantiator.java:57) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
          at org.jboss.as.web.deployment.component.WebComponentInstantiator.getReference(WebComponentInstantiator.java:55) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4
  ]
          at org.jboss.as.web.deployment.WebInjectionContainer.instantiate(WebInjectionContainer.java:102) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
          at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:81) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
          at org.jboss.as.web.deployment.WebInjectionContainer.newInstance(WebInjectionContainer.java:75) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
          at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1156) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:372) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:679) [jbossweb-7.0.17.Final-redhat-1.jar:]
          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:931) [jbossweb-7.0.17.Final-redhat-1.jar:]
  </code></pre>
  
  <p>I noticed that there is defproject key you can set called <a href="https://github.com/weavejester/lein-ring#resources" rel="nofollow">:war-resources-path</a> so I put my properties file into the $PROJECT_ROOT/war-resources directory (<a href="https://github.com/weavejester/lein-ring#resources" rel="nofollow">the default</a> for that), and I'm still not having any luck.</p>
  
  <p>Does anyone know the best way to read from a properties file using <code>lein ring uberwar</code>?</p>