Scala与Java 9不兼容 - java.lang.NoClassDefFoundError

时间:2017-10-01 19:24:53

标签: java scala sbt java-9

在我的电脑上安装Java 9之后运行一个示例Scala SBT项目,我接受了这个例外。 我已经尝试了一些我发现的解决方案,但没有。

Java 9和Scala之间是否存在任何不兼容性?

Scala版本:2.12.3

Java版本:java版本" 9"

IDE:IntelliJ

提前致谢。

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)

我试过这个但是没有用。

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

2 个答案:

答案 0 :(得分:4)

尝试添加编译器选项以暂时解决此问题:

--add-modules java.se.ee

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

以来

您还可以在scala-dev存储库中跟踪问题Support JDK 9 以获取更新。

答案 1 :(得分:0)

我只是删除Java 9,直到有人给我一些灯光并且编译正常。