Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.ClassNotFoundException: java.util.Base64 error in clojure

Tags:

java

clojure

I'm learning clojure in Ubuntu(Linux) OS. I'm facing an unexpected error. Everything is working fine in my system. When I move same code & data in different system, I got an error. I run following command:

$ lein run 
Exception in thread "main" java.lang.ClassNotFoundException: java.util.Base64, compiling:(com/data/common/jwt.clj:86:23)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6875)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.access$300(Compiler.java:38)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6269)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler$IfExpr$Parser.parse(Compiler.java:2797)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6001)
    at clojure.lang.Compiler$LetExpr$Parser.parse(Compiler.java:6319)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler$IfExpr$Parser.parse(Compiler.java:2797)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:6001)
    at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5380)
    at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3972)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6866)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6856)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.access$300(Compiler.java:38)
    at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:589)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6868)
    at clojure.lang.Compiler.analyze(Compiler.java:6669)
    at clojure.lang.Compiler.analyze(Compiler.java:6625)
    at clojure.lang.Compiler.eval(Compiler.java:6931)
    at clojure.lang.Compiler.load(Compiler.java:7379)
    at clojure.lang.RT.loadResourceScript(RT.java:372)
    at clojure.lang.RT.loadResourceScript(RT.java:363)
    at clojure.lang.RT.load(RT.java:453)
    at clojure.lang.RT.load(RT.java:419)
    at clojure.core$load$fn__5677.invoke(core.clj:5893)
    at clojure.core$load.invokeStatic(core.clj:5892)
    at clojure.core$load.doInvoke(core.clj:5876)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5697)
    at clojure.core$load_one.invoke(core.clj:5692)
    at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
    at clojure.core$load_lib.invokeStatic(core.clj:5736)
    at clojure.core$load_lib.doInvoke(core.clj:5717)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$load_libs.invokeStatic(core.clj:5774)
    at clojure.core$load_libs.doInvoke(core.clj:5758)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$require.invokeStatic(core.clj:5796)
    at clojure.core$require.doInvoke(core.clj:5796)
    at clojure.lang.RestFn.invoke(RestFn.java:703)
    at binutils.core$eval20$loading__5569__auto____21.invoke(core.clj:1)
    at binutils.core$eval20.invokeStatic(core.clj:1)
    at binutils.core$eval20.invoke(core.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6927)
    at clojure.lang.Compiler.eval(Compiler.java:6916)
    at clojure.lang.Compiler.load(Compiler.java:7379)
    at clojure.lang.RT.loadResourceScript(RT.java:372)
    at clojure.lang.RT.loadResourceScript(RT.java:363)
    at clojure.lang.RT.load(RT.java:453)
    at clojure.lang.RT.load(RT.java:419)
    at clojure.core$load$fn__5677.invoke(core.clj:5893)
    at clojure.core$load.invokeStatic(core.clj:5892)
    at clojure.core$load.doInvoke(core.clj:5876)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at clojure.core$load_one.invokeStatic(core.clj:5697)
    at clojure.core$load_one.invoke(core.clj:5692)
    at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
    at clojure.core$load_lib.invokeStatic(core.clj:5736)
    at clojure.core$load_lib.doInvoke(core.clj:5717)
    at clojure.lang.RestFn.applyTo(RestFn.java:142)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$load_libs.invokeStatic(core.clj:5774)
    at clojure.core$load_libs.doInvoke(core.clj:5758)
    at clojure.lang.RestFn.applyTo(RestFn.java:137)
    at clojure.core$apply.invokeStatic(core.clj:648)
    at clojure.core$require.invokeStatic(core.clj:5796)
    at clojure.core$require.doInvoke(core.clj:5796)
    at clojure.lang.RestFn.invoke(RestFn.java:408)
    at user$eval5$fn__7.invoke(form-init2263747695343924382.clj:1)
    at user$eval5.invokeStatic(form-init2263747695343924382.clj:1)
    at user$eval5.invoke(form-init2263747695343924382.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6927)
    at clojure.lang.Compiler.eval(Compiler.java:6917)
    at clojure.lang.Compiler.load(Compiler.java:7379)
    at clojure.lang.Compiler.loadFile(Compiler.java:7317)
    at clojure.main$load_script.invokeStatic(main.clj:275)
    at clojure.main$init_opt.invokeStatic(main.clj:277)
    at clojure.main$init_opt.invoke(main.clj:277)
    at clojure.main$initialize.invokeStatic(main.clj:308)
    at clojure.main$null_opt.invokeStatic(main.clj:342)
    at clojure.main$null_opt.invoke(main.clj:339)
    at clojure.main$main.invokeStatic(main.clj:421)
    at clojure.main$main.doInvoke(main.clj:384)
    at clojure.lang.RestFn.invoke(RestFn.java:421)
    at clojure.lang.Var.invoke(Var.java:383)
    at clojure.lang.AFn.applyToHelper(AFn.java:156)
    at clojure.lang.Var.applyTo(Var.java:700)
    at clojure.main.main(main.java:37)
Caused by: java.lang.ClassNotFoundException: java.util.Base64
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:69)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
    at clojure.lang.DynamicClassLoader.loadClass(DynamicClassLoader.java:77)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:270)
    at clojure.lang.RT.classForName(RT.java:2168)
    at clojure.lang.RT.classForName(RT.java:2177)
    at clojure.lang.Compiler$HostExpr.maybeClass(Compiler.java:1030)
    at clojure.lang.Compiler.macroexpand1(Compiler.java:6807)
    at clojure.lang.Compiler.analyzeSeq(Compiler.java:6854)
    ... 107 more

lein retrieve required library, but I'm not sure whether It retrieve all required lib or not. I don't understand, why it is happening? can anyone help me to fix this error? Thanks.

like image 832
rishi kant Avatar asked Oct 19 '22 04:10

rishi kant


1 Answers

It's likely that your Java version is lower than 8.

You can either switch to use Java 8 to run your compiled clojure code (or update to Java 8 if you don't have one), or use Base64 from Apache Commons Codec library, you can check this post for detail: java.lang.NoClassDefFoundError: java/util/Base64

like image 185
John Avatar answered Oct 21 '22 04:10

John