Fork me on GitHub
#leiningen
<
2020-06-11
>
qmrw23:06:31

would anyone like to help prevent a suicide? I need some help generating a functioning uberjar.

noisesmith23:06:30

for future reference, you're more likely to get help if you describe the problem - what exactly goes wrong?

qmrw23:06:36

thanks, I have a dependency on a project that has a custom java component. eveyrthing is working fine via lein run, however if I attempt to generate an uberjar and run it. It complains;

java -jar target/uberjar/tickfest-0.1.0-SNAPSHOT-standalone.jar
Exception in thread "main" java.lang.NoClassDefFoundError: qwrap/core/qDict (wrong name: qwrap/core/QDict)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)

noisesmith23:06:37

do you define a class called qDict with the q lower case?

noisesmith23:06:42

or perhaps use deftype or defrecord to create something called qDict?

qmrw23:06:42

the author of the dependency defines a record, yes

noisesmith23:06:19

yeah, the normal solution would be to name it as expected - with the first letter capitalized

qmrw23:06:08

why does it work fine under lein run ?

noisesmith23:06:12

alternatively you can avoid aot (using clojure.main as your entry point, not using gen-class), which causes the class to be loaded the same way it would when using lein run

noisesmith23:06:30

because class files from a resource are not defined the same way as ones created in memory by clojure

noisesmith23:06:16

when you do (defrecord Foo ...) in clojure, clojure directly compiles the byte code for a class Foo and injects it into the vm, this is not the same as looking up a class in a jar, and clojure is less picky about things like naming conventions

noisesmith23:06:03

so you can have names that work without aot, and break with aot, if you don't follow the java naming rules

qmrw23:06:07

I see, great catch -- I didn't even notice the case difference in the error.

qmrw23:06:37

I'll try a simple rename in my fork of the repo and see if that helps

qmrw23:06:04

thanks a lot for your help