After installing JDK9, I get this exception when running my Scala projects. Upgrading Scala to 2.12.2 also didn't resolve my problem.
Asked
Active
Viewed 4.8k times
20
-
3You might want to **[move to using `jaxb-api:2.3.0`](https://stackoverflow.com/a/46221811/1746118)** to solve this ideally. – Naman Sep 20 '17 at 15:27
-
Possible duplicate of [Intellij: SBT-based Scala project does not build with Java 9](https://stackoverflow.com/questions/46381242/intellij-sbt-based-scala-project-does-not-build-with-java-9) – user8664964 Sep 25 '17 at 23:41
-
are you found the solution @abshar – Surajkaran Meghwanshi Jan 10 '23 at 06:15
3 Answers
11
The java.xml.bind
module is not resolved by default when running code on the module path. This means that if you depend on JAXB then you need to run with --add-modules java.xml.bind
or else deploy JAXB on the class path (or module path).
Update: The "Modules Shared with Java EE Not Resolved by Default" section of JDK 9 Migration Guide provides more information on this topic.

Alan Bateman
- 5,283
- 1
- 20
- 25
-
2
-
1in theory this is the solution, but how do you ask scala/sbt to add this argument when they run java? – Aero Wang Nov 17 '17 at 08:32
-
What do you think about ```javaOptions in ThisBuild += "--add-modules=ALL-SYSTEM"``` – Epicurist Jan 24 '18 at 15:14
-
```javaOptions in ThisBuild += "--add-modules=java.xml.bind"``` would be better. Do mind the equal sign! Tested with Java version "9.0.4" – Epicurist Jan 24 '18 at 15:44
-
-
0
To add to the previous answer I would like to refer to the following answer: https://stackoverflow.com/a/43574427/3751268. I think it covers in details which is the desired way to provide libraries like the jaxb
.
In particular for Scala, I add it like this to my libraryDependencies
:
libraryDependencies += Seq("javax.xml.bind" % "jaxb-api" % "2.3.0")

aitorhh
- 2,331
- 1
- 23
- 35