Open n2o opened 7 years ago
The module javax.xml.bind
has been renamed and is also deprecated as of Java 9, so it might be a good idea to migrate to another implementation for the future.
A workaround would be adding --add-modules java.xml.bind
to the javac
compilation and java
call as suggested here.
I'm just starting with Clojure and Java so -- can someone tell me how to work around this? what do I need to add to the standard "lein new figwheel
I'm on a mac.
I've downloaded javax.xlm from mvnrepository (version 2.3).
I've added :javac-options ["--add-modules java.xml.bind" to my project.clj
I'm still getting the error mentioned above.
java 9.0.1 Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
Leiningen 2.8.1 on Java 9.0.1 Java HotSpot(TM) 64-Bit Server VM
Looks like you need to add the flag to :jvm-opts
in project.clj
, like this:
:jvm-opts ["--add-modules" "java.xml.bind"]
I switched back to JDK 8 for now to continue developing in clojurescript.
OK I fixed this in the figwheel template. So that if someone is generating a project from Java 9
It adds
:jvm-opts ["--add-modules" "java.xml.bind"]
To the project.clj
https://github.com/bhauman/figwheel-template/commit/627fa1d95d19682ebcc39627c2785eaa70482e22
I'm leaving this open so that people find it.
I would like to point out, that by adding :jvm-opts ["--add-modules" "java.xml.bind"]
you are breaking Java 8 support since flag --add-modules
is only recognized by Java 9. The only real solution for this is to migrate away from java.xml.bind
or to wait that Clojure adds support for Java modules so that Figwheel could declare the module dependency correctly (meaning, generate module-info.java
within jar).
Here is a slightly less hacky hack (pun intended) to bypass this problem:
:jvm-opts ~(concat
; Normal JVM opts to pass in
["-Xmx1g"]
; Java 9+ recognition, adding --add-modules. Java versions before 9
; had a different version syntax where they contained '.' delimiters,
; from Java 9 onwards it has a simple versioning scheme based on one
; number.
(if (false? (.contains (System/getProperty "java.version") "."))
["--add-modules" "java.xml.bind"]
[]))
This should work with all existing versions of Java. Not exactly pretty but at least it works as a workaround while we wait for the proper fix.
:edit:
Sigh. As a hack that obviously doesn't work with Cursive. Since Cursive is doing it's own bit of magic on evaluating what is within project.clj
it does not support arbitrary code execution via ~
to define project.clj
definitions dynamically. Well, Cider/Fireplace guys should be happy with that at least I guess. :P
:edit 2:
Cursive problem is a local one and thus it can be solved locally (meaning, you should know what Java version you are running yourself). Add this to your Run Configuration and it should work with Cursive too:
That's odd, I got a version number 9.0.1
. could we do a split on the .
s and check if the first element is 9?
edit: What worked for me is:
(let [version (System/getProperty "java.version")
[major _ _] (clojure.string/split version #"\.")]
(if (>= (Integer. major) 9)
["--add-modules" "java.xml.bind"]
[]))
edit2: coerce string to number as per @empperi 's suggestion
@levitanong Maybe also parse it to number and make comparison that it is equal or greater to 9?
This might also be useful https://docs.oracle.com/javase/9/docs/api/java/lang/Runtime.Version.html, though not sure how far back it's available (only 9?).
@empperi Yes, that would be much better! @danielcompton If it's only 9, wouldn't it throw on <9?
@levitanong yeah it would, you could do some fancy loading stuff. Was just throwing it out there as an idea, though maybe not a great one.
In general, I find it is far preferable to make a decision based on the presence or absence of a class that can be loaded vs the version string (which they are in the process of radically changing for java). For example, check whether you can (Class/forName "javax.xml.bind.DatatypeConverter")
.
@puredanger I agree but in this case doing that will cause try-catching and whatnot which just adds to the already noisy hack which shouldn't even be in project.clj
. Like we all agree I think, the best solution for this is just to fix figwheel (and a whole bunch of other libraries out there) to not use javax.xml.bind
stuff. Considering that what most use is javax.xml.bind.DatatypeConverter
like you mentioned above and that stuff is mostly for JAXB (which is pretty much useless for Clojure apps) it shouldn't be too big of a problem.
@empperi I'm pretty sure the issue is actually with ClojureScript, not Figwheel, I can't see figwheel using DatatypeConverter
anywhere. The next version of ClojureScript should fix this. See my post on updating to Java 9 for more details.
Sorry to bump this up but the latest Clojurescript release 1.10 fixes this issue. The figwheel-core at https://github.com/bhauman/lein-figwheel/blob/933e01c69a0bd2d25e47eb3dc6213bf9d24909a2/figwheel-core/project.clj#L11
It has the updated dependency and the other modules have the old dependency. I don't know the places where this needs to be updated but just wanted to add it has been resolved without the need to use jvm-opts
and add-modules
options.
Relevant JIRA : https://dev.clojure.org/jira/browse/CLJS-2377
Hey thanks but you don't need to update this in the core tooling projects.
Users need to update the cljs dependency in their own projects.
This forces users to use 1.10 when that is not necessary yet.
On Mar 29, 2018, at 7:50 AM, Xtreak notifications@github.com wrote:
Sorry to bump this up but the latest Clojurescript release 1.10 fixes this issue. The figwheel-core at https://github.com/bhauman/lein-figwheel/blob/933e01c69a0bd2d25e47eb3dc6213bf9d24909a2/figwheel-core/project.clj#L11
It has the updated dependency and the other modules have the old dependency. I don't know the places where this needs to be updated but just wanted to add it has been resolved without the need to use jvm-opts and add-modules options.
Relevant JIRA : https://dev.clojure.org/jira/browse/CLJS-2377
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Now that ClojureScript 1.10.238 is out, perhaps the template should depend on it. Perhaps a new http-kit
dependency should be brought in as well to avoid the same problem.
This would allow users on Java 9 or 10 to do
lein new figwheel myproject
without encountering errors.
I've just updated figwheel and figwheel-template to address the Java 9 problems https://github.com/bhauman/lein-figwheel/commit/6fb335961311bf172094cc05d392c40bbde66696 https://github.com/bhauman/lein-figwheel/commit/ce8fddcf25a066d4a4753fd7822dbc2a87d14d02#diff-4367e1e3b4d141bc25ecb930cb78b5aaR11 https://github.com/bhauman/figwheel-template/commit/45d1de6e060390857b2bbb2a35c23a0e6bd20a32
FYI, seeing same error printed out using JDK 10. Works after downgrading back to JDK 8.
Nvm! Mistake on my end. Works fine with JDK 10!
@jlo1 are you seeing exactly the same error? Can you print out the full stack trace and share which versions of ClojureScript and Figwheel you have? The error may be coming from another dependency, not Figwheel.
Sadly, like @jlo1 (before he realized his mistake), I'm am getting this error with JDK10. I'm new enough to Clojure and CLJS (and Java), I don't have the Google-fu to troubleshoot this.
Here's the full stack trace:
➜ flappy-bird-demo git:(master) lein figwheel
Figwheel: Cutting some fruit, just a sec ...
Exception in thread "main" java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(cljs/util.cljc:1:1)
at clojure.lang.Compiler.load(Compiler.java:7391)
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:805)
at cljs.analyzer$eval2662$loading__5569__auto____2663.invoke(analyzer.cljc:9)
at cljs.analyzer$eval2662.invokeStatic(analyzer.cljc:9)
at cljs.analyzer$eval2662.invoke(analyzer.cljc:9)
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:457)
at figwheel_sidecar.utils$eval2656$loading__5569__auto____2657.invoke(utils.clj:1)
at figwheel_sidecar.utils$eval2656.invokeStatic(utils.clj:1)
at figwheel_sidecar.utils$eval2656.invoke(utils.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:1096)
at figwheel_sidecar.config$eval21$loading__5569__auto____22.invoke(config.clj:1)
at figwheel_sidecar.config$eval21.invokeStatic(config.clj:1)
at figwheel_sidecar.config$eval21.invoke(config.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:436)
at figwheel_sidecar.build_utils$eval15$loading__5569__auto____16.invoke(build_utils.clj:1)
at figwheel_sidecar.build_utils$eval15.invokeStatic(build_utils.clj:1)
at figwheel_sidecar.build_utils$eval15.invoke(build_utils.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:930)
at figwheel_sidecar.repl_api$eval9$loading__5569__auto____10.invoke(repl_api.clj:1)
at figwheel_sidecar.repl_api$eval9.invokeStatic(repl_api.clj:1)
at figwheel_sidecar.repl_api$eval9.invoke(repl_api.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.invokeStatic(form-init13598116903115428154.clj:1)
at user$eval5.invoke(form-init13598116903115428154.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.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: javax.xml.bind.DatatypeConverter
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:466)
at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:69)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:566)
at clojure.lang.DynamicClassLoader.loadClass(DynamicClassLoader.java:77)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:374)
at clojure.lang.RT.classForName(RT.java:2168)
at clojure.lang.RT.classForNameNonLoading(RT.java:2181)
at cljs.util$eval2668$loading__5569__auto____2669.invoke(util.cljc:9)
at cljs.util$eval2668.invokeStatic(util.cljc:9)
at cljs.util$eval2668.invoke(util.cljc:9)
at clojure.lang.Compiler.eval(Compiler.java:6927)
at clojure.lang.Compiler.eval(Compiler.java:6916)
at clojure.lang.Compiler.load(Compiler.java:7379)
... 181 more
Subprocess failed
I'm running brand-spanking new installations of Java, Clojure, ClojureScript, and Figwheel. This is effectively the result of the following, on Mac OS, executed today:
> brew cask install java
> brew install clojure
> brew install leiningen
> git clone https://github.com/bhauman/flappy-bird-demo.git
> cd flappy-bird-demo
> lein figwheel
Versions:
Java: 10.0.1
Clojure: 1.8.0
Leiningen: 2.8.1
FWIW, the hello-world option for getting started works just fine. Also: apologies if I should be barking up some other tree. Thanks!
@kredati please try with Clojurescript 1.10.234 in the project.clj of the flappy bird demo.
core.async 0.3.442 if you are going to use clojure 1.9 and above.
Hope it helps.
Thanks.
Thanks for the quick reply!
Downgrading the Clojurescript and core.async versions didn't help, and produces the identical error, sorry to say.
Ultimately, I suspect it's user error on my end, but I don't know enough (coming from JS-land) to know what it is I've got munged up. That said, I'm happy to help figure out what the problem might be so other beginners don't get caught up with the same bug. Also am not especially looking for tech support.
Thanks!
@kredati I could verify the same issues you had on https://github.com/bhauman/flappy-bird-demo. On that project, the dependencies were a bit older, so compilation would fail. I've made a PR to update the dependencies there, if you apply those changes to your local copy everything should run ok.
I also wrote a more detailed guide on upgrading at https://www.deps.co/blog/how-to-upgrade-clojure-projects-to-use-java-9/ which covers why these changes need to be made.
I got this same error with OpenJDK 11.
:jvm-opts ["--add-modules" "java.xml.bind"]
After trying this, I get another error:
java.lang.module.FindException: Module java.xml.bind not found
EDIT: I resolved it by adding this as a dependency:
[javax.xml.bind/jaxb-api "2.4.0-b180830.0359"]
@Jarzka that module is completely gone from the JDK in JDK11, hence needing to add it as a dependency. See https://www.deps.co/blog/how-to-upgrade-clojure-projects-to-use-java-11/ for more details on the upgrade to JDK11.
Hey,
I am getting a ClassNotFoundException after I installed Java 9 on my machine. That's the setup:
I am using leiningen and commented out line 218 in
lein
to avoid another Exception (as suggested here):I also tried the latest snapshot of leiningen, which throws the same exception:
When you then create a new figwheel-project and try to start it, it throws with both leiningen installations the same error:
Thanks for your help!