Trouble with running AKKA project

I'm learning AKKA and I've started with a simple example

build.sbt

version := "1.0"
ThisBuild / name := "akka-quickstart-scala"
ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "3.3.1-RC1"
lazy val akkaVersion = "2.8.2"
fork := true

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor-typed" % akkaVersion,
  "ch.qos.logback" % "logback-classic" % "1.4.6",
  "com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion % Test,
  "com.typesafe.akka" %% "akka-actor" % akkaVersion,
  "org.scalatest" %% "scalatest" % "3.2.15" % Test
)

Scala file

package com.example

import akka.actor.typed.{ActorSystem, Behavior}
import akka.actor.typed.scaladsl.{ActorContext, Behaviors}
import com.example.OrderProcessor.Order

import java.util.UUID

object OrderProcessor {
  case class Order(id: UUID, product: String, price: BigDecimal)

  def apply(): Behavior[Order] = Behaviors.receive {
    (context, message) =>

      context.getLog.info(s"${message.product} costs ${message.price}")
      println(s"${message.product} costs ${message.price}")
      Behaviors.same
  }
}

object AkkaQuickstart extends App {
val orderProcessor: ActorSystem[OrderProcessor.Order] = ActorSystem(OrderProcessor(), "orders")


  orderProcessor ! Order(UUID.randomUUID(), "Jacket", BigDecimal("10.00"))
orderProcessor ! Order(UUID.randomUUID(), "Double bass", BigDecimal("100000.00"
}

project/build.properties

sbt.version=1.5.5

(also tried with 1.9.0)

src/main/resources/application.conf

akka {
loglevel = "DEBUG"

  stdout-loglevel = "DEBUG"
}

I also have a logback.xml

Problem description

I can run the code it with IDE only, sbt run fails with "No configuration setting found for key 'akka'"

$ sbt run
[info] welcome to sbt 1.5.5 (Azul Systems, Inc. Java 11.0.19)
[info] loading global plugins from /home/jacek/.sbt/1.0/plugins
[info] loading project definition from /home/jacek/IdeaProjects/!/akka-quickstart-scala/project
[info] loading settings for project root from build.sbt ...
[info] set current project to akka-quickstart-scala (in build file:/home/jacek/IdeaProjects/!/akka-quickstart-scala/)
[warn] there's a key that's not used by any other settings/tasks:
[warn]  
[warn] * ThisBuild / version
[warn]   +- /home/jacek/IdeaProjects/!/akka-quickstart-scala/build.sbt:5
[warn]  
[warn] note: a setting might still be used by a command; to exclude a key from this `lintUnused` check
[warn] either append it to `Global / excludeLintKeys` or call .withRank(KeyRanks.Invisible) on the key
[info] running (fork) com.example.AkkaQuickstart 
[error] Exception in thread "main" java.lang.ExceptionInInitializerError
[error]         at com.example.AkkaQuickstart.main(AkkaQuickstart.scala)
[error] Caused by: com.typesafe.config.ConfigException$Missing: system properties: No configuration setting found for key 'akka'
[error]         at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:157)
[error]         at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:150)
[error]         at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:177)
[error]         at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189)
[error]         at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:194)
[error]         at com.typesafe.config.impl.SimpleConfig.getList(SimpleConfig.java:263)
[error]         at com.typesafe.config.impl.SimpleConfig.getHomogeneousUnwrappedList(SimpleConfig.java:383)
[error]         at com.typesafe.config.impl.SimpleConfig.getStringList(SimpleConfig.java:441)
[error]         at akka.actor.ActorSystem$Settings$.amendSlf4jConfig(ActorSystem.scala:336)
[error]         at akka.actor.ActorSystemImpl.<init>(ActorSystem.scala:833)
[error]         at akka.actor.typed.ActorSystem$.createInternal(ActorSystem.scala:289)
[error]         at akka.actor.typed.ActorSystem$.apply(ActorSystem.scala:198)
[error]         at com.example.AkkaQuickstart$.<clinit>(AkkaQuickstart.scala:25)
[error]         ... 1 more
[error] Nonzero exit code returned from runner: 1
[error] (Compile / run) Nonzero exit code returned from runner: 1
[error] Total time: 1 s, completed Jun 4, 2023, 12:49:03 PM

I also tried for "Clusters" sample project downloaded from https://doc.akka.io/docs/akka/current/project/examples.html

I tried sbt package clean, running on different JVM, rescan indexes

I open a jar, the settings.conf is there. I've been searching and trying different solution from SO and other places for hours, no luck.

0

请先登录再写评论。