clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
vnctaing 2020-10-12T02:36:05.338100Z

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.

jumar 2020-10-12T03:48:53.338700Z

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

vnctaing 2020-10-12T04:24:06.339100Z

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

seancorfield 2020-10-12T04:43:14.340100Z

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

vnctaing 2020-10-12T05:27:25.340400Z

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

vnctaing 2020-10-12T05:40:17.340600Z

(The git repo is: https://github.com/vnctaing/tartataing)

jumar 2020-10-12T06:08:38.341Z

@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

jumar 2020-10-12T06:09:26.341300Z

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

vnctaing 2020-10-12T06:25:18.342800Z

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

Chris K 2020-10-12T09:57:05.346300Z

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

javahippie 2020-10-12T10:02:32.346400Z

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 K 2020-10-12T10:07:09.346700Z

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

simongray 2020-10-12T10:16:38.346900Z

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

Chris K 2020-10-12T10:55:11.347400Z

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

simongray 2020-10-12T11:45:14.347600Z

Read the link for terms and conditions

Chris K 2020-10-12T12:27:46.348300Z

thanks

2020-10-12T17:06:01.352800Z

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?

vncz 2020-10-12T17:09:32.353300Z

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

ghadi 2020-10-12T17:13:27.354700Z

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

2020-10-12T17:45:16.358900Z

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.

alexmiller 2020-10-12T18:15:38.359900Z

More info here: https://clojure.org/guides/faq#illegal_access

vncz 2020-10-12T18:43:24.360500Z

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

borkdude 2020-10-12T18:55:49.361200Z

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

ghadi 2020-10-12T18:56:46.362Z

what was your actual test @vincenz.chianese?

Setzer22 2020-10-12T19:11:33.363200Z

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

thom 2020-10-12T19:31:04.366Z

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

Setzer22 2020-10-12T20:11:32.366400Z

thanks!

vncz 2020-10-12T22:25:58.367200Z

Running a Pedestal app with Clojure

vncz 2020-10-12T22:26:02.367400Z

@ghadi @borkdude

emccue 2020-10-12T23:29:58.368500Z

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

emccue 2020-10-12T23:30:26.369100Z

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

thom 2020-10-12T23:30:34.369500Z

Measure!

emccue 2020-10-12T23:30:58.369800Z

not deployed yet - hobby project

alexmiller 2020-10-12T23:31:23.370500Z

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

emccue 2020-10-12T23:31:59.371600Z

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

alexmiller 2020-10-12T23:33:01.372700Z

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

alexmiller 2020-10-12T23:34:00.374Z

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

emccue 2020-10-12T23:34:57.374600Z

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

emccue 2020-10-12T23:35:35.375400Z

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

emccue 2020-10-12T23:35:57.375900Z

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