Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassNotFoundException error when project has java source files #166

Open
insaneparachute opened this issue Nov 10, 2016 · 7 comments

Comments

@insaneparachute
Copy link

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

@yogthos
Copy link
Member

yogthos commented Nov 10, 2016

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.

@ccherng
Copy link

ccherng commented Nov 27, 2016

@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

@insaneparachute
Copy link
Author

insaneparachute commented Mar 14, 2017

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 ?

@lsyoyo
Copy link

lsyoyo commented Mar 11, 2019

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

@lsyoyo
Copy link

lsyoyo commented Mar 11, 2019

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.

@lsyoyo
Copy link

lsyoyo commented Mar 12, 2019

After some digging, I found this issue - luminus-framework/luminus-template#319, and it might be helpful for whoever gets here.

@yogthos
Copy link
Member

yogthos commented Mar 12, 2019

So, the problem was that the user namespace was trying to load code before it was compiled then?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants