What happened to akka.util.duration?

In a lot of old Akka examples you will see the following statements:

import akka.util.Timeout
import akka.util.duration._
implicit val askTimeout = Timeout(1 second)

This will give error ‘object duration is not a member of package akka.util’. It turns out duration is now included in Scala standard library. To fix the error use the following import statement:

import scala.concurrent.duration._

Check out the migration guide for other pieces of Akka functionality that have moved to Scala.


Executing a method defined in a configuration file

I have a class with a method that takes a function as parameter. This function is the strategy that determines how a file is split into chunks. This is the signature of the method.

def split(r: RemoteFileInfo, append: Boolean, workDir: File, strategy: (Long) => Int = defaultStrategy): LinkedHashSet[Chunk] = {

There is a companion object that provides a number of predefined strategies. I wanted to make the strategy configurable by adding it to the Akka application.conf file. Continue reading

ClassNotFoundException when adding slf4j to Akka

When adding to a Akka project I got the following error java.lang.ClassNotFoundException: akka.event.slf4j.Slf4jLogger. I double checked my configuration and the Akka documentation. The documentation says the following:

Akka provides a logger for SL4FJ. This module is available in the ‘akka-slf4j.jar’. It has one single dependency; the slf4j-api jar. In runtime you also need a SLF4J backend, we recommend Logback.

No success. Continue reading