java.lang.ClassNotFoundException error when project has java source files
I created a basic luminus app using
lein new luminus myapp
and added
:java-source-paths ["src/java"] in project.clj file
and added a simple java file src/java/com/example/Hello.java
package com.example;
public class Hello
{
public static String getFoo()
{
return "foo";
}
}
In src/clj/myapp/routes/home.clj, I'm referencing this function getFoo()
When I run lein javac
It gives me an error
java.lang.ClassNotFoundException: com.example.Hello
That seems correct, but not sure why it's not compiling in your case. I have a similar setup here, and it compiles fine using both lein javac and in Cursive.
@insaneparachute @yogthos I encountered this same problem A project created with lein new luminus chess +auth +swagger +cljs What I discovered is that if you delete the :profiles key and its value then lein javac curiously works fine. Full details at http://stackoverflow.com/questions/40824115/lein-javac-tries-to-compile-clojure-code-and-fails I would also like to know how to fix this
Hi, I've been able to get around this problem by using the DEBUG mode on lein (DEBUG=true lein javac), copying the /tmp/.leiningen-cmdlineXXXX.tmp file created by lein into the root directory of the app and running a javac using the parameters in the tmp file.
Is this the correct way to go about this or is there a better way to do this, @yogthos ?
@insaneparachute @yogthos , I think I run into the same issue. The project is generated using +site.
I'm able to make the uberjar work by adding :prep-tasks ["javac" "compile" ["cljsbuild" "once" "min"]] into the uberjar profile. However the dev profile for command lein repl still doesn't work. I'm resorting to temporarily remove java code references from (ns .. calls to start a repl, then adding the java references back would work. But those are not fun to do.
I was able to make a minimal project to reproduce the issue I see. https://github.com/lsyoyo/test-repl-error, clone and run lein repl to see the error.
After some digging, I found this issue - https://github.com/luminus-framework/luminus-template/issues/319, and it might be helpful for whoever gets here.
So, the problem was that the user namespace was trying to load code before it was compiled then?