sbt test - NoClassDefFoundError
Asked Answered
X

0

6

I have a scala app that I build with sbt. It pulls in a native library. The native library is loaded via...

System.setProperty("java.library.path", "libs")
System.loadLibrary("native-library")

The app runs absolutely fine on both Ubuntu 14 and 16. I can execute sbt test and run no problem and it all links up perfectly.

I am testing out building on Ubuntu 18 and am running into issues. They seem to be specifically related to loading/linking the native library. The app runs fine if I use "sbt run". However if I try "sbt test" it fails with the following error...

sbt.ForkMain$ForkError: java.lang.NoClassDefFoundError: Could not initialize class "MyClass"

where "MyClass" is the class that links the native library. The app also compiles fine (sbt compile) and I have included "fork := true" in my build.sbt.

So I know it "works" in some scenarios. There just seems to be something specific about "sbt test" where it breaks.

Thanks!

Xenophobe answered 9/10, 2018 at 22:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.