Scala不兼容Java 9 - Java .lang. noclassdeffounderror

时间:2021-05-22 17:27:08

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.

在我的pc上安装了Java 9之后,您只需运行一个Scala SBT项目示例,我采取了这个例外。我已经尝试了一些解决方案,但没有找到。

Is there any incompatibility between Java 9 and Scala?

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

Scala Version: 2.12.3

Scala版本:2.12.3

Java Version: java version "9"

Java版本:Java版本“9”

IDE: IntelliJ

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 Scala不兼容Java 9 - Java .lang. noclassdeffounderror

——添加模块java.xml。绑定或者——添加模块java.se.ee

2 个解决方案

#1


4  

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.

由于Java EE共享的模块在JDK9中不会被默认解析。

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

您还可以跟踪这个问题,以便在scala-dev存储库中支持JDK 9进行更新。

#2


0  

I just remove Java 9 until someone gives me some lights and the compile works as usual.

我只是删除了Java 9,直到有人给我一些提示,编译工作正常。

#1


4  

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.

由于Java EE共享的模块在JDK9中不会被默认解析。

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

您还可以跟踪这个问题,以便在scala-dev存储库中支持JDK 9进行更新。

#2


0  

I just remove Java 9 until someone gives me some lights and the compile works as usual.

我只是删除了Java 9,直到有人给我一些提示,编译工作正常。