scalasbtakkaakka-actor

Scala sbt tests: "No configuration setting found for key 'akka'" after switching to Java 11


After switching to Java 11, sbt tests started to fail with the exception "No configuration setting found for key 'akka'". We are using sbt assembly plugin on the project but since the tests are run not inside jar but using sbt <module_name>/test, looks like there are some issues with building test resources/paths.

List of things I did:

  1. Added concat MergeStrategy for 'reference.conf' file. Jar that is assembled has all files inside and there are no issues with that, so it is only a test step issue.
  2. Checked class path for tests using 'export <module_name>/test:fullClasspath' in sbt before and after migrating to Java 11. They are the same.

Everything else except of a test where I create actor system works good. Code that creates actor system:

object MyObjectTest extends AsyncFunSuite {
  private implicit val system: ActorSystem = ActorSystem("MyActorSystem")
  private implicit val ex: ExecutionContext = system.dispatcher
}

At the moment I do not have any ideas what should I check next, so any suggestions would be appreciated.

P.S. running tests inside IDEA works good, but we have CI/CD job that runs tests using sbt test command.


Solution

  • I guess there are some issues when you are using sbt + Java 11. I tried to reproduce this error using a small project with the same configuration but was not been able to do it. However, the issue was fixed using the following option in sbt:

    Test / fork := true
    

    According to sbt documentation, this property creates a separate JVM for running all tests. I think all configurations have been set up correctly for another JVM.

    Hope this answer will help someone in future.