Search code examples
clojurejvmleiningen

Clojure gorilla repl and JVM 10 exception


Linux Manjaro 17.1.11

OpenJDK 64-Bit Server VM (build 10.0.1+10, mixed mode)

Leiningen 2.8.1 on Java 10.0.1 OpenJDK 64-Bit Server VM

Starting a new project for testing gorilla-repl:

$ lein new app gorilla-test

Added gorilla to project.clj:

:plugins [[lein-gorilla "0.4.0"]] 

Get an exception when running:

$ lein gorilla

the exception:

clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(org/httpkit/server.clj:1:1) .....

.....

.....

Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter

......

......

Tried:

There's a closed issue for http-kit on github here. It is suggested to add the following to the project.clj

:jvm-opts ["--add-modules" "java.xml.bind”]

or to add to java startup: --add-modules java.xml.bind

The lein option doesn't help and the java startup option i tried using export in the shell, but that rendered JVM fatal exception.

If there is another way to configure the JVM (which ofcourse there is) I don't know my way around... I found many references to the exception by searching, but none that assume no knowledge of the JVM mechanism...

examples : 1 2

EDIT (work-a-round):

Decided to rollback to JVM 8, Java 1.8.

I also found newer version of the gorilla repl in clojars.com. and went for this one

Works!

Perhaps it would have worked with the new Java runtime, but I decided to press all the buttons at once...


Solution

  • Another option is to add [javax.xml.bind/jaxb-api "2.3.0"] as a dependency. However, similar to the :jvm-opts the dependencies don't apply to plugins (like lein-gorilla) since they are run separately.

    You can either modify the original plugin and add jaxb-api to its dependencies (which I did in this PR: https://github.com/JonyEpsilon/lein-gorilla/pull/12) or you can "fake it" by adding jaxb-api to the :plugins vector in your project.clj:

    :plugins [[javax.xml.bind/jaxb-api "2.3.0"]
             [lein-gorilla "0.4.0"]])