Uploaded image for project: 'Immutant'
  1. Immutant
  2. IMMUTANT-609

document org.immutant/wildfly dependency in installation & wildfly guides

    Details

    • Type: Documentation
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.1.2
    • Fix Version/s: 2.1.3
    • Labels:
      None
    • Environment:

      immutant 2.1.2
      lein-immutant 2.1.0

      The lein immutant war task / aot

      Description

      The usability of the immutant.wildfly namespace and its contained vars depends on whether or not the application is actually deployed inside the container. If we are deployed on the container, you are injecting the org.immutant/wildfly (mvn) dependency. Yet this injection does not extend to compiling the project ahead of time.

      Assume you have an application doing the following (src/iflyaot/core.clj):

      (ns iflyaot.core
        (:require 
          [immutant.wildfly :as ifly]
          [immutant.web :as iweb]
          [clojure.tools.logging :as log])
        (:gen-class))
       
       
      (defn app [r]
        {:status 200
         :body "something"})
       
      (defn -main [& args]
          (log/info "Starting app"
                                "context" (ifly/context-path)
                                "base-uri" (ifly/base-uri))
          (iweb/run app))
      

      With the following project.clj:

      (defproject 
        iflyaot "0.1.0-SNAPSHOT"
        :description "FIXME: write description"
        :url "http://example.com/FIXME"
        :main iflyaot.core
        :license {:name "Eclipse Public License"
                  :url "http://www.eclipse.org/legal/epl-v10.html"}
        :dependencies [
          [org.clojure/clojure "1.7.0"] 
          [org.immutant/immutant "2.1.2"] 
          [org.clojure/tools.logging "0.3.1"]]
        :plugins [[lein-immutant "2.1.0"]])
      

      This will work fine when using the dev war deployment option of lein immutant war, because it avoids AOT. But if you try to compile the project, either explicitly (lein compile) or by producing an uberjar to include in the war (lein immutant war non-dev), you will stumble over an error such as:

      $ lein immutant war -o ~/local/wildfly                             
      Warning: specified :main without including it in :aot. 
      Implicit AOT of :main will be removed in Leiningen 3.0.0. 
      If you only need AOT for your uberjar, consider adding :aot :all into your
      :uberjar profile instead.
      Compiling iflyaot.core
      java.io.FileNotFoundException: Could not locate immutant/wildfly__init.class or immutant/wildfly.clj on classpath., compiling:(core.clj:1:1)
      Exception in thread "main" java.io.FileNotFoundException: Could not locate immutant/wildfly__init.class or immutant/wildfly.clj on classpath., compiling:(core.clj:1:1)
      	at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3628)
      	at clojure.lang.Compiler.compile1(Compiler.java:7323)
      	at clojure.lang.Compiler.compile1(Compiler.java:7313)
      	at clojure.lang.Compiler.compile(Compiler.java:7390)
      	at clojure.lang.RT.compile(RT.java:399)
      	at clojure.lang.RT.load(RT.java:444)
      	at clojure.lang.RT.load(RT.java:412)
      	at clojure.core$load$fn__5448.invoke(core.clj:5866)
      	at clojure.core$load.doInvoke(core.clj:5865)
      	at clojure.lang.RestFn.invoke(RestFn.java:408)
      	at clojure.core$load_one.invoke(core.clj:5671)
      	at clojure.core$compile$fn__5453.invoke(core.clj:5877)
      	at clojure.core$compile.invoke(core.clj:5876)
      	at user$eval9$fn__18.invoke(form-init7742110784358565553.clj:1)
      	at user$eval9.invoke(form-init7742110784358565553.clj:1)
      	at clojure.lang.Compiler.eval(Compiler.java:6782)
      	at clojure.lang.Compiler.eval(Compiler.java:6772)
      	at clojure.lang.Compiler.load(Compiler.java:7227)
      	at clojure.lang.Compiler.loadFile(Compiler.java:7165)
      	at clojure.main$load_script.invoke(main.clj:275)
      	at clojure.main$init_opt.invoke(main.clj:280)
      	at clojure.main$initialize.invoke(main.clj:308)
      	at clojure.main$null_opt.invoke(main.clj:343)
      	at clojure.main$main.doInvoke(main.clj:421)
      	at clojure.lang.RestFn.invoke(RestFn.java:421)
      	at clojure.lang.Var.invoke(Var.java:383)
      	at clojure.lang.AFn.applyToHelper(AFn.java:156)
      	at clojure.lang.Var.applyTo(Var.java:700)
      	at clojure.main.main(main.java:37)
      Caused by: java.io.FileNotFoundException: Could not locate immutant/wildfly__init.class or immutant/wildfly.clj on classpath.
      	at clojure.lang.RT.load(RT.java:449)
      	at clojure.lang.RT.load(RT.java:412)
      	at clojure.core$load$fn__5448.invoke(core.clj:5866)
      	at clojure.core$load.doInvoke(core.clj:5865)
      	at clojure.lang.RestFn.invoke(RestFn.java:408)
      	at clojure.core$load_one.invoke(core.clj:5671)
      	at clojure.core$load_lib$fn__5397.invoke(core.clj:5711)
      	at clojure.core$load_lib.doInvoke(core.clj:5710)
      	at clojure.lang.RestFn.applyTo(RestFn.java:142)
      	at clojure.core$apply.invoke(core.clj:632)
      	at clojure.core$load_libs.doInvoke(core.clj:5749)
      	at clojure.lang.RestFn.applyTo(RestFn.java:137)
      	at clojure.core$apply.invoke(core.clj:632)
      	at clojure.core$require.doInvoke(core.clj:5832)
      	at clojure.lang.RestFn.invoke(RestFn.java:436)
      	at iflyaot.core$loading__5340__auto____25.invoke(core.clj:1)
      	at clojure.lang.AFn.applyToHelper(AFn.java:152)
      	at clojure.lang.AFn.applyTo(AFn.java:144)
      	at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3623)
      	... 28 more
      Compilation failed: Subprocess failed
      

      This is a case where the user knows more than the environment. For AOTing something that we know is going to be deployed on a wildfly container, and where bits and pieces of immutant.wildfly are to be used, we need to explicitly add the org.immutant/wildfly dependency, i.e. add [org.immutant/wildfly "2.1.2"] to above sample's dependency vector in project.clj to fix the issue.

      I suggest documenting this fact twofold:

      1. There is no mention of the availability of the org.immutant/wildfly package in the installation guide. Where it explains the individual contents of the org.immutant/immutant super package, I suggest adding mention of org.immutant/wildfly (and its current version) including a note "for wildfly deployments". Additionally the installation guide references the wildfly guide.
      2. The wildfly guide should detail the issue: explain the mechanic of the org.immutant/wildfly injection and how you can make this explicit if you're both only deploying on wildfly and using immutant.wildfly explicitly in your application

      (in tcrawley's words: "if you are using something explicitly from the immutant.wildfly ns and need to AOT, you'll need to depend on it")

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                jcrossley Jim Crossley
                Reporter:
                martin-s-weber Martin S. Weber
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: