Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala incompatibility with Java 9 - java.lang.NoClassDefFoundError

Just run a sample Scala SBT project after installing Java 9 on my pc and I took this exception. I already tried some solutions that I found but nothing.

Is there any incompatibility between Java 9 and Scala?

Scala Version: 2.12.3

Java Version: java version "9"

IDE: IntelliJ

Thanks in advance.

info] Compiling 7 Scala sources and 1 Java source to /Users/ermis/Projects/begining-scala/target/scala-2.12/classes...
[info] p.a.h.EnabledFilters - Enabled Filters (see <https://www.playframework.com/documentation/latest/Filters>):

play.filters.csrf.CSRFFilter
play.filters.headers.SecurityHeadersFilter
play.filters.hosts.AllowedHostsFilter

[info] play.api.Play - Application started (Dev)
Uncaught error from thread [play-dev-mode-akka.actor.default-
dispatcher-2]: javax/xml/bind/DatatypeConverter, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for for ActorSystem[play-dev-mode]
java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
    at io.jsonwebtoken.impl.Base64Codec.decode(Base64Codec.java:26)
    at io.jsonwebtoken.impl.DefaultJwtBuilder.signWith(DefaultJwtBuilder.java:106)
    at play.api.mvc.JWTCookieDataCodec$JWTFormatter.format(Cookie.scala:710)
    at play.api.mvc.JWTCookieDataCodec.encode(Cookie.scala:569)
    at play.api.mvc.JWTCookieDataCodec.encode$(Cookie.scala:567)
    at play.api.mvc.DefaultJWTCookieDataCodec.encode(Cookie.scala:760)
    at play.api.mvc.FallbackCookieDataCodec.encode(Cookie.scala:734)
    at play.api.mvc.FallbackCookieDataCodec.encode$(Cookie.scala:733)
    at play.api.mvc.DefaultSessionCookieBaker.encode(Session.scala:95)
    at play.api.mvc.CookieBaker.encodeAsCookie(Cookie.scala:414)
    at play.api.mvc.CookieBaker.encodeAsCookie$(Cookie.scala:413)
    at play.api.mvc.DefaultSessionCookieBaker.encodeAsCookie(Session.scala:95)
    at play.api.mvc.Result.$anonfun$bakeCookies$2(Results.scala:281)
    at scala.Option.map(Option.scala:146)
    at play.api.mvc.Result.bakeCookies(Results.scala:280)
    at play.core.server.common.ServerResultUtils.prepareCookies(ServerResultUtils.scala:227)
    at play.core.server.AkkaHttpServer.$anonfun$executeAction$3(AkkaHttpServer.scala:302)
    at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)
    at akka.http.scaladsl.util.FastFuture$.transformWith$extension1(FastFuture.scala:55)
    at akka.http.scaladsl.util.FastFuture$.flatMap$extension(FastFuture.scala:26)
    at play.core.server.AkkaHttpServer.executeAction(AkkaHttpServer.scala:301)
    at play.core.server.AkkaHttpServer.executeHandler(AkkaHttpServer.scala:254)

I tried this but didn't work.

--add-modules java.xml.bind or --add-modules java.se.ee enter image description here

like image 443
pik4 Avatar asked Oct 01 '17 19:10

pik4


Video Answer


1 Answers

Try adding a compiler option to temporarily fix this:

--add-modules java.se.ee

since the Module shared by Java EE would not be resolved by default in JDK9.

You can also keep track of the issue to Support JDK 9 at scala-dev repository for updates as well.

like image 75
Naman Avatar answered Sep 28 '22 22:09

Naman