Skip to content

Random InvocationTargetExceptions when compiling hybrid Java/Maven module #379

@pkozikow

Description

@pkozikow

Assuming there is a file src/clojure/name/myns.clj that looks like this in a maven module

(ns name.myns
  (:import ....
           [my_package MyJavaClass]))

(def my-field (.myMethod (MyJavaClass.)))

I get the following error:
Error:clojure: java.lang.reflect.InvocationTargetException, compiling:(myns.clj:X:Y)
every time I edit myns.clj

where X:Y point to the my-field declaration.

The same code compiles fine with mvn from the command line. It may be important to note that La Clojure has the exact same behavior.

The workaround is to go to the clojure compiler settings and select "Don't compile Clojure namespaces", compile the project, and then restore the compiler settings. It makes little sense that after doing that the compiler no longer fails with the above error and everything works until I edit the file again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions