Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding clojure dependency and running lein uberjar causes java.lang.IllegalAccessError

I am a novice engineer with experience writing PHP, python, and ruby. I am trying to contribute to a project written in clojure. I am trying to add a library to the project, but after adding the library and running lein uberjar, I am receiving an error. I would like to know what it means and whether you can recommend a method for troubleshooting it. Thank you in advance for your help!

What I am trying to achieve Include the uap-clj library in my project and compile the project into a jarfile.

What I wrote I have added the library as the second-to-last item in the dependencies list.

  :dependencies [[lots-of-dependencies]
                 [uap-clj "1.1.1"] ; user agent parser
                 [another-dependency]] 

What I ran in lein According to the instructions on github, after saving my changes to project.clj, I run lein deps then lein clean && lein uberjar.

What happened After updating and saving the file, running the command gives the following error before a long stacktrace:

java.lang.IllegalAccessError: tried to access method clojure.lang.RT.classForNameNonLoading(Ljava/lang/String;)Ljava/lang/Class; from class clj_yaml.core$loading__5340__auto____29, compiling:(flexmaster.clj:1:1)

What else I tried I wanted to test whether I had made a mistake adding the library. I created a new clojure project from scratch and created a jarfile using lein deps and then lein uberjar. Next, I added uap-clj to the :dependencies in my new project, saved project.clj, and executed lein deps and lein uberjar again. I was able to successfully create a jarfile, so I believe I am adding the library correctly.

I cannot think of another reason why the act of including another dependency would prevent me from creating the jarfile. If you can think of something I should check based on the information I provided, it would help me very much. Thank you!

like image 322
Desiree Cox Avatar asked Sep 26 '22 01:09

Desiree Cox


1 Answers

It looks like the referenced library depends on Clojure 1.7.0, but you're explicitly referencing version 1.6.0.

Try changing:

[org.clojure/clojure "1.6.0"]

to:

[org.clojure/clojure "1.7.0"]

Alternatively, you could reference an older version of the library which doesn't depend on Clojure 1.7.0, like: [uap-clj "1.0.1"]

like image 64
Derek Slager Avatar answered Nov 15 '22 11:11

Derek Slager