Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Play/Scala, JDK17, Apple M1: NoClassDefFoundError: Could not initialize class com.sun.jna.Native #51

Open
michbarsinai opened this issue Apr 2, 2022 · 7 comments

Comments

@michbarsinai
Copy link

When working with Play, using JDK17 on Apple Silicon M1, I get the below stack trace. The problem is solved when moving back to JDK11.

(sbt 1.6.2, Play 2.8.15)

[info] Sass compiling on 7 source(s)
[error] stack trace is suppressed; run last Web-assets / sassify for the full output
[error] (Web-assets / sassify) java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
[error] a.a.ActorSystemImpl - Internal server error, sending 500 response
akka.http.impl.util.One2OneBidiFlow$OutputTruncationException: Inner flow was completed without producing result elements for 1 outstanding elements
	at akka.http.impl.util.One2OneBidiFlow$OutputTruncationException$.apply(One2OneBidiFlow.scala:22)
	at akka.http.impl.util.One2OneBidiFlow$OutputTruncationException$.apply(One2OneBidiFlow.scala:22)
	at akka.http.impl.util.One2OneBidiFlow$One2OneBidi$$anon$1$$anon$4.onUpstreamFinish(One2OneBidiFlow.scala:97)
	at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:524)
	at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:390)
	at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:650)
	at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:521)
	at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:625)
	at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:800)
	at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:818)
@irundaia
Copy link
Owner

irundaia commented Apr 3, 2022

Hi Michael,

Could you clarify which version of sbt-sassify you're using? I'm trying to reproduce this issue, but I cannot on my intel Mac.

@michbarsinai
Copy link
Author

michbarsinai commented Apr 3, 2022 via email

@irundaia
Copy link
Owner

irundaia commented Apr 3, 2022

Great that you'd like to help resolve this issue. Would it be possible for you to provide your plugins.sbt and build.sbt files? I personally wouldn't expect this to be an CPU architecture issue, but rather a dependency conflict.

@michbarsinai
Copy link
Author

plugins.sbt

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.15")

addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.6")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.4")

addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.2")

addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.2")

addSbtPlugin("io.github.irundaia" % "sbt-sassify" % "1.5.2")

build.sbt:

import play.sbt.PlayImport.caffeine

name := """XXXXX"""

organization := "XXXX"

maintainer := "XXXXXXX"

version := "0.7-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.13.7"

// Targeting JDK11, which is the current LTS
javacOptions ++= Seq("-source", "11", "-target", "11")

libraryDependencies ++= Seq(
  caffeine,
  ws,
  guice,
  "com.google.inject"            % "guice"                % "5.1.0", /* Needed for JDK17 */
  "com.google.inject.extensions" % "guice-assistedinject" % "5.1.0", /* Needed for JDK17 */
  "io.methvin" % "directory-watcher" % "0.15.0", /* Required for M1 */
  "com.typesafe.play" %% "play-slick" % "5.0.0",
  "com.typesafe.play" %% "play-slick-evolutions" % "5.0.0",
  "com.typesafe.play" %% "play-mailer" % "8.0.0",
  "com.typesafe.play" %% "play-mailer-guice" % "8.0.0",
  "be.objectify" %% "deadbolt-scala" % "2.7.1",
  "org.mindrot" % "jbcrypt" % "0.3m",
  "org.postgresql" % "postgresql" % "42.2.11",
  "org.webjars" % "jquery" % "3.6.0",
  "org.webjars" % "jquery-ui" % "1.12.1",
  "org.webjars.bower" % "tether" % "1.4.7",
  "org.webjars" % "popper.js" % "2.9.2",
  "org.webjars" % "sweetalert" % "2.1.0",
  "org.webjars.bower" % "polyglot" % "2.2.2",
  "org.webjars" % "bootstrap" % "5.1.3",
  "org.webjars.bower" % "fontawesome" % "4.7.0",
  "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3" % Test,
  "org.seleniumhq.selenium" % "selenium-java" % "2.35.0" % Test,
)


import org.irundaia.sbt.sass._

SassKeys.cssStyle := Minified

SassKeys.generateSourceMaps := true

// Needed for M1/Apple Silicon
PlayKeys.fileWatchService := play.dev.filewatch.FileWatchService.jdk7(play.sbt.run.toLoggerProxy(sLog.value))

TwirlKeys.templateImports ++= Seq("views.Helpers")

pipelineStages := Seq(digest, gzip)

// Disable documentation creation
Compile / doc / sources  := Seq.empty
Compile / packageDoc / publishArtifact := false

@giannoug
Copy link

Same issue here on an Apple M1 machine. Using sbt 1.4.9 and Play 2.7.9.

[error] stack trace is suppressed; run last my-project / Web-assets / sassify for the full output
[error] (my-project / Web-assets / sassify) java.lang.UnsatisfiedLinkError: /Users/user/Library/Caches/JNA/temp/jna4151150526563459761.tmp: dlopen(/Users/user/Library/Caches/JNA/temp/jna4151150526563459761.tmp, 0x0001): tried: '/Users/user/Library/Caches/JNA/temp/jna4151150526563459761.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/user/Library/Caches/JNA/temp/jna4151150526563459761.tmp' (no such file), '/Users/user/Library/Caches/JNA/temp/jna4151150526563459761.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64'))
[error] a.a.ActorSystemImpl - Internal server error, sending 500 response
akka.http.impl.util.One2OneBidiFlow$OutputTruncationException: Inner flow was completed without producing result elements for 1 outstanding elements
	at akka.http.impl.util.One2OneBidiFlow$OutputTruncationException$.apply(One2OneBidiFlow.scala:22)
	at akka.http.impl.util.One2OneBidiFlow$OutputTruncationException$.apply(One2OneBidiFlow.scala:22)
	at akka.http.impl.util.One2OneBidiFlow$One2OneBidi$$anon$1$$anon$4.onUpstreamFinish(One2OneBidiFlow.scala:97)
	at akka.stream.impl.fusing.GraphInterpreter.processEvent(GraphInterpreter.scala:506)
	at akka.stream.impl.fusing.GraphInterpreter.execute(GraphInterpreter.scala:376)
	at akka.stream.impl.fusing.GraphInterpreterShell.runBatch(ActorGraphInterpreter.scala:606)
	at akka.stream.impl.fusing.GraphInterpreterShell$AsyncInput.execute(ActorGraphInterpreter.scala:485)
	at akka.stream.impl.fusing.GraphInterpreterShell.processEvent(ActorGraphInterpreter.scala:581)
	at akka.stream.impl.fusing.ActorGraphInterpreter.akka$stream$impl$fusing$ActorGraphInterpreter$$processEvent(ActorGraphInterpreter.scala:749)
	at akka.stream.impl.fusing.ActorGraphInterpreter$$anonfun$receive$1.applyOrElse(ActorGraphInterpreter.scala:764

@cheburan
Copy link

Any luck with this?

@ruddhikamm
Copy link

[info] Sass compiling on 6 source(s)
[trace] Stack trace suppressed: run last web-assets:sassify for the full output.
[error] (web-assets:sassify) java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/hv/dytqzpts2fd675j4rsbp6p2c0000gp/T/jna-1086956152/jna6666156284613827565.tmp
[error] p.c.s.n.PlayRequestHandler - Exception caught in Netty
scala.MatchError: java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/hv/dytqzpts2fd675j4rsbp6p2c0000gp/T/jna-1086956152/jna6666156284613827565.tmp (of class java.lang.UnsatisfiedLinkError)
at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:44)
at play.sbt.run.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:44)
at scala.Option.map(Option.scala:145)
at play.sbt.run.PlayReload$.taskFailureHandler(PlayReload.scala:44)
at play.sbt.run.PlayReload$.compileFailure(PlayReload.scala:40)
at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
at play.sbt.run.PlayReload$$anonfun$compile$1.apply(PlayReload.scala:17)
at scala.util.Either$LeftProjection.map(Either.scala:377)
at play.sbt.run.PlayReload$.compile(PlayReload.scala:17)
at play.sbt.run.PlayRun$$anonfun$playRunTask$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$2.apply(PlayRun.scala:61)

Facing Same Issue. JDK 8 Apple silicon M1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants