Fork me on GitHub
#clojure
<
2020-10-12
>
vnctaing02:10:05

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.

jumar03:10:53

Looks like your core.clj namespace isn't really there - are you sure you got the path/name correct?

vnctaing04:10:06

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

seancorfield04:10:14

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. @U62LF4PT5

vnctaing05:10:25

@U04V70XH6 The template included a (:gen-class) in the core.clj file, it’s surprising to have this warning

jumar06:10:38

@U62LF4PT5 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

jumar06:10:26

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

vnctaing06:10:18

Ah adding a gen-class to file in the prod folder made the error disappear thanks !

Chris K09:10:05

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

javahippie10:10:32

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/

Chris K10:10:09

is this book up to date? and would I get new copies if it gets updated?

simongray10:10:38

The third edition is literally coming out next month, so yeah, it is surely up to date.

Chris K10:10:11

oh.. didn't know that. so if I were to buy should I buy now or wait? sorry maybe a bit stupid question ;( @U4P4NREBY

simongray11:10:14

Read the link for terms and conditions

fadrian17:10:01

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?

vncz17:10:32

I also had likely the same issue (with both HotSpot and J9), downgraded to 11 for now.

ghadi17:10:27

--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

fadrian17:10:16

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.

vncz18:10:24

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

borkdude18:10:49

@vincenz.chianese Did you compare it with Clojure or pure Java?

ghadi18:10:46

what was your actual test @vincenz.chianese?

Setzer2219:10:33

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...)

thom19:10:04

@U086BARD5’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.

vncz22:10:58

Running a Pedestal app with Clojure

emccue23:10:58

how bad is the performance cost of reflection for stuff that isn't numerics?

emccue23:10:26

(I just set *warn-on-reflection* to true and I got yelled at)

thom23:10:34

Measure!

emccue23:10:58

not deployed yet - hobby project

Alex Miller (Clojure team)23:10:23

Is it in a loop? If so, it’s worth fixing

emccue23:10:59

its not in a loop, its calls to .close and .getResource on my connection pools operating per request

Alex Miller (Clojure team)23:10:01

Well that’s not going to be anything that you notice

Alex Miller (Clojure team)23:10:00

So it’s a matter of how clean you want to be

emccue23:10:57

the reason I am asking at all is because I remember hearing that method handles can be optimized by the JIT in java 8+

emccue23:10:35

So i didn't know if clojure does its reflection in a way that can be optimized (or if it could)

emccue23:10:57

not that it is a mission critical performance thing - I haven't measured and I have zero users