Arthur C
Arthur C

Reputation: 1274

application.conf is not loaded

I've put application.conf in src/main/resources, but the configuration doesn't load when I run my application. I have for instance a custom Akka mailbox defined in application.conf. It returns an error:

akka.ConfigurationException: Mailbox Type [custom-mailbox] not configured.

How can I fix this? I'm running a test application Test.scala which extends App. I run it as a Scala application. Is this the problem?

EDIT

As requested, my application.conf:

akka {
    loggers = ["akka.event.slf4j.Slf4jLogger"]
    loglevel = "INFO"
    stdout-loglevel = "INFO"

    seatclaimer-mailbox {
        mailbox-type = "com.ticketo.seating.SeatClaimer$SeatClaimerMailbox"
    }
}

Upvotes: 1

Views: 734

Answers (2)

Xiaoyu Ma
Xiaoyu Ma

Reputation: 1

The config file must be in the classpath, but src/main/resources is not included in the default classpath which is a unmanaged resources. It means you need to add it to your project classpath manually. It's easy to do this in eclipse, or add (unmanagedSourceDirectories in Compile) <+= baseDirectory(_ /"src/main/resources") to your build.sbt

Upvotes: 0

Arthur C
Arthur C

Reputation: 1274

I found the problem. The config did load but the mailbox couldn't be found. Firstly, my addressing was incorrect.

Props(new SeatClaimer(seatingZone)).withMailbox("seatclaimer-mailbox")

"seatclaimer-mailbox" has to be "akka.seatclaimer-mailbox".

Secondly, the location of the mailbox in application.conf was incorrect. I changed it to "com.ticketo.seating.SeatClaimerMailbox".

Upvotes: 1

Related Questions