testcontainers / testcontainers-scala

Docker containers for testing in scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NoClassDefFoundError: munit/Test - With `testcontainers-scala-munit` versions above 0.40.14

benomac opened this issue · comments

Hi, we're getting this error

[error] This may be due to the ClassLoaderLayeringStrategy (ScalaLibrary) used by your task.
[error] To improve performance and reduce memory, sbt attempts to cache the class loaders used to load the project dependencies.
[error] The project class files are loaded in a separate class loader that is created for each test run.
[error] The test class loader accesses the project dependency classes using the cached project dependency classloader.
[error] With this approach, class loading may fail under the following conditions:
[error] 
[error]  * Dependencies use reflection to access classes in your project's classpath.
[error]    Java serialization/deserialization may cause this.
[error]  * An open package is accessed across layers. If the project's classes access or extend
[error]    jvm package private classes defined in a project dependency, it may cause an IllegalAccessError
[error]    because the jvm enforces package private at the classloader level.
[error] 
[error] These issues, along with others that were not enumerated above, may be resolved by changing the class loader layering strategy.
[error] The Flat and ScalaLibrary strategies bundle the full project classpath in the same class loader.
[error] To use one of these strategies, set the  ClassLoaderLayeringStrategy key
[error] in your configuration, for example:
[error] 
[error] set service / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.ScalaLibrary
[error] set service / Test / classLoaderLayeringStrategy := ClassLoaderLayeringStrategy.Flat
[error] 
[error] See ClassLoaderLayeringStrategy.scala for the full list of options

When upgrading our testcontainers version to anything above 0.40.14. We've tried changing the ClassLoaderLayeringStrategy to Flat, the only effect this has had is changing part of the error message
from
[error] This may be due to the ClassLoaderLayeringStrategy (ScalaLibrary)
to
[error] This may be due to the ClassLoaderLayeringStrategy (Flat)
scala version - 3.3.0
sbt version - 1.6.2

We've also tried updating Munit to the latest version with no effect.
Any help would be greatly appreciated. Thanks.

Bumping all related libraries to current versions, that is
munit to 1.0.0-M10
munit-cats-effect to 2.0.0-M3
testcontainers-scala-munit to 0.41.0
should fix this binary incompatibility

Bumping all related libraries to current versions, that is munit to 1.0.0-M10 munit-cats-effect to 2.0.0-M3 testcontainers-scala-munit to 0.41.0 should fix this binary incompatibility

I guess that means it can be closed now. Worth noting that at the time the ticket was opened, bumping munit and munit-cats-effect to the latest version didn't fix it.