Hi, I’m trying to deploy a brand new repository using the Luminus template on Heroku. But I get errors on the live app Logs from Heroku
2020-10-12T02:12:41.936928+00:00 app[web.1]: "Execution error (FileNotFoundException) at clojure.main/main (main.java:40).\nCould not locate <my_repo_name>/core__init.class, <my_repo_name>/core.clj or <my_repo_name>/core.cljc on classpath.\n",
project.clj:
....
{:uberjar {:omit-source true
:prep-tasks ["compile" ["shadow" "release" "app"]]
:aot :all
:uberjar-name "<my_repo_name>.jar"
:source-paths ["env/prod/clj" "env/prod/cljs" ]
:resource-paths ["env/prod/resources"]}
....
Also I got an error while it was running lein uberjar
during deployment, not sure if relevant
Warning: The Main-Class specified does not exist within the jar. It may not be executable as expected. A gen-class directive may be missing in the namespace which contains the main method, or the namespace has not been AOT-compiled.
Looks like your core.clj namespace isn't really there - are you sure you got the path/name correct?
I’m still new to Clojure, so I’m not sure.
When I run lein run
, the app works correctly.
I tried to run heroku run bash
, then lein classpath
output a big path string.
I also tried this
~ $ clj -Spath | sed -e 's/:/\'$'\n/g' | head
src
/app/.m2/repository/org/clojure/clojure/1.10.0/clojure-1.10.0.jar
/app/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar
/app/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar
Ah, that warning from lein uberjar
suggests that your core ns does not have (:gen-class)
in the ns
form -- that's required for AOT compilation. Since you're omitting source from the JAR, there will be no .clj
file for Clojure to find -- which it is trying to do because Leiningen couldn't find the main class (because there was no (:gen-class)
in the ns
form), so it probably built the JAR to run clojure.main
as the main class. @vnctaing
@seancorfield The template included a (:gen-class)
in the core.clj file, it’s surprising to have this warning
(The git repo is: https://github.com/vnctaing/tartataing)
@vnctaing
I don't see the tartataing.core
here (no core.clj file): https://github.com/vnctaing/tartataing/tree/main/src/clj/tartataing
But it's set as :main
in project.clj: https://github.com/vnctaing/tartataing/blob/main/project.clj#L49
:main ^:skip-aot tartataing.core
Ah, you only have it in your dev
folder - that's the reason I suppose it works with lein run
but doesn't work with uberjar: https://github.com/vnctaing/tartataing/blob/main/env/dev/clj/tartataing/core.clj
Ah adding a gen-class to file in the prod folder made the error disappear thanks !
Any books for learning luminus or any detailed book that talks about web development in clojure? I tried some online resources but I found them to just skim through the basic ideas but not enough that I was hoping for... It would be great if it was free too
I have not read it, yet, but web development and luminus are covered in this book: https://pragprog.com/titles/dswdcloj3/web-development-with-clojure-third-edition/
is this book up to date? and would I get new copies if it gets updated?
The third edition is literally coming out next month, so yeah, it is surely up to date.
oh.. didn't know that. so if I were to buy should I buy now or wait? sorry maybe a bit stupid question ;( @simongray
Read the link for terms and conditions
thanks
I've just downloaded OpenJDK 15 and installed it. I attempted to run a program that previously ran in this environment, but lein run errors out: WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by clojure.lang.Reflector$$InjectedInvoker/0x0000000800bb4440 (file: .../.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar) to method com.sun.xml.internal.stream.XMLInputFactoryImpl.createXMLStreamReader(http://java.io.Reader) Any idea what's going on between Clojure 1.10.1 and OpenJDK 15? It looks like a runtime incompatibility of some sort. What versions of JDK does Clojure 1.10.1 support?
I also had likely the same issue (with both HotSpot and J9), downgraded to 11 for now.
--illegal-access debug
are useful options. My guess is you're using clojure.xml, which is unofficially deprecated (will be officially in upcoming release). Switch to clojure.data.xml @fadrian
Thanks, @vincenz.chianese, @ghadi - The version I was using for com.vincit.clj-xsd.core was using an old version of clojure.data.xml (0.2.0-alpha2). I upgraded the xsd parser to alpha6, but the problem still remained. I downgraded to JDK-11 and that worked.
More info here: https://clojure.org/guides/faq#illegal_access
By the way I've tried OpenJ9 which says that uses low memory and rapid startup — it does not really seem to be the case
@vincenz.chianese Did you compare it with Clojure or pure Java?
what was your actual test @vincenz.chianese?
I have a zipper (locator), is there any function that will tell me the sequence of steps I need to follow from the root of the tree to reach it? (in e.g. zip/down zip/right...)
@zcaudate’s zip library maintained history as you traversed. Doing it in reverse is a bit trickier obv but you should just be able to loop/recur to the top while counting how many left siblings you have at each level.
thanks!
Running a Pedestal app with Clojure
how bad is the performance cost of reflection for stuff that isn't numerics?
(I just set *warn-on-reflection*
to true and I got yelled at)
Measure!
not deployed yet - hobby project
Is it in a loop? If so, it’s worth fixing
its not in a loop, its calls to .close
and .getResource
on my connection pools operating per request
Well that’s not going to be anything that you notice
So it’s a matter of how clean you want to be
the reason I am asking at all is because I remember hearing that method handles can be optimized by the JIT in java 8+
So i didn't know if clojure does its reflection in a way that can be optimized (or if it could)
not that it is a mission critical performance thing - I haven't measured and I have zero users