problem using boot-clj to build uberjar that starts up a component based system

154 views
Skip to first unread message

Matthias Sattel

unread,
Jul 13, 2015, 9:53:22 AM7/13/15
to clo...@googlegroups.com
I am currently using the component library from Stuart Sierra to build up a system. So far it works on the repl and in my tests, but somehow when I build the uberjar using boot.clj and execute it, the system doesn't start.

(defn -main
  "Startup the embedded http server and the other components."
  [& args]
  ;(start-server)
  (let [system (system/my-system {})]
    (do
      (info "Try to start my system " system)
      (component/start system))))

And my-system is build as follows:

(defn my-system [config-options]
  (do
    (info "Building my system")
    (-> (component/system-map
         :my-storage (my-storage-test-component/new-storage)
         :http (http-component/new-http-server (http-port (:http-port config-options)) (wrap-handler)))
        (component/system-using {:http {:storage :my-storage}}))
    ))

I added those log outputs because I am new to clojure and have not debugged clj code yet.
On the repl I can call the -main function and it startsup the system as expected, but when I build an uberjar with boot and start it, then it just logs the two info messages on the command line, then it seems to do nothing for some seconds and then it stops.

Any help would be great, maybe you guys can tell me how I can find the problem. Can I somehow debug into that when I run the jar file??? Could it be a problem with aot?

This is my boot config:
(task-options!
    pom {
        :project 'my-project
        :version "0.1.0-SNAPSHOT" }
    aot {:namespace '#{myproject.embedded-main}}
    jar {
        :manifest {"description" "Testing boot"}
        :main 'myproject.embedded-main })

(deftask build
     "Building the project"
     []
     (comp
        (aot)
        (pom)
        (uber)
        (jar)
        (install)))

Ragnar Dahlén

unread,
Jul 13, 2015, 9:58:34 AM7/13/15
to clo...@googlegroups.com
Hi Matthias,

I encountered similar symptoms (basically a corrupt uberjar) which I eventually tracked down to file handle leaks and fixed in: https://github.com/boot-clj/boot/pull/228

This PR has been merged but not been released yet, so I'd give boot master a go and see if that fixes your problem.

Colin Yates

unread,
Jul 13, 2015, 9:59:33 AM7/13/15
to clo...@googlegroups.com
Assuming -main is defined in myproject/embedded-main.clj then you need to know Java doesn’t like - in filenames so the actual class is my project.embedded_main. It is fine to include - when referring to Clojure construct (symbols etc.), but when defining a Java construct you need to use “_”.

Also, you don’t need (do…) in your defns like that.

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthias Sattel

unread,
Jul 13, 2015, 5:05:11 PM7/13/15
to clo...@googlegroups.com
Hi Ragnar,
your fix solved my issue. With the latest boot version I can build the uberjar and start the system as expected. Thanks a lot. So far I like boot a lot, very interesting build tool.
Reply all
Reply to author
Forward
0 new messages