I've tried to switch my Scala/sbt based project to Java 9. If I compile the project with sbt, it works.
If I try to build the project with the Build option of IntelliJ, I get immediately the error
Error:Module 'xyz' production: java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
I've tried to add the module as dependency
libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.0"
and added in the compiler settings of IntelliJ (javac as well the scala compiler)
<option name="ADDITIONAL_OPTIONS_STRING" value="--add-modules java.xml.bind" />
but does not help, unfortunately.
We recommend that you upgrade to sbt versions 1.0 and later which are compatible with the Scala version 2.12 (requires Java 8).
Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Build Tools | sbt. In the sbt projects section, select a project for which you want to configure build actions. In the sbt shell section, select the builds option. Click OK to save the changes.
To start working with Scala in IntelliJ IDEA you need to download and enable the Scala plugin. If you run IntelliJ IDEA for the first time, you can install the Scala plugin when IntelliJ IDEA suggests downloading featured plugins. Otherwise, you can use the Settings | Plugins page for the installation.
You can temporarily switch to another version of Scala using ++<version> . This version does not have to be listed in your build. scala. versions property, but it does have to be in a repository or be a local Scala version you have defined.
In addition to the above answers.
If you are not using IntelliJ and running the program from sbt console, I found the following resolved the issue:
Adding the following to your build.sbt:
libraryDependencies += "javax.xml.bind" % "jaxb-api" % "2.3.0"
Adding the import statement to your controller:
import javax.xml._
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With