SOLVED: Scala Akka Typed: how to add a Jackson module to avoid de-serialization error of Address

Hi,

I am having trouble de-serializing a Map[Address,Job] inside a State object. The problem stems from the fact that the de-serializer for the Address is not found. For this test:

    k.testKit.serializationTestKit.verifySerialization(trq1)

I get the error:

Test concurrency.WorkStealSpec.testJacksonSerializationState failed: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a (Map) Key deserializer for type [simple type, class akka.actor.Address]
 at [Source: (byte[])"�estate�dtypeiTestStatedjobs��kjobsPending�takka://WorkStealSpec�dtypeiFailFirstbidP�V��Lk����r�hattemptshdurationdPT0SangCPUTimefPT0.1SpCPUDeviationTimedPT0SffailAt�dtypefNoFail���jjobsFailed��mjobsRemaininggCPUTimefPT0.1SpCPUDeviationTimedPT0SffailAt�dtypefNoFail��greplyToxAakka://WorkStealSpec@127.0.0.1:25255/system/testProbe-1#981770887�"; line: -1, column: 13] (through reference chain: concurrency.Consumer$ProducerState["state"]), took 1.977 sec

So I encoded a Jackson de-serializer as follows:

case class AkkaAddressOut() extends KeyDeserializer {
  override def deserializeKey(key: String, ctxt: DeserializationContext): Address = {
    AddressFromURIString(key)
  }
}

case object MyAkkaJacksonModule extends SimpleModule {
    addKeyDeserializer( classOf[Address], AkkaAddressOut() )
}

If I test directly in Jackson so:

    val tstate = TestState(1, 100.millis, 0.millis, NoFail())

    val cborTJ1: Array[Byte] = mapper.writeValueAsBytes(tstate)
    val tj1p  = mapper.readValue(cborTJ1, classOf[TestState])
    assertEquals("Same state (7)", ntstate, tj1p)

This works correctly. So I can confirm its the Map that is the problem. Now here is the issue, how do I add this module via the configuration file? The following attempt does not work:

akka.serialization.jackson {
    jackson-modules += "concurrency.MyAkkaJacksonModule"
} 

What is more intriguing is that I have found:

That leads me to:

So I assume that the associated de-serializer should already be available. What is more this is part of the internal API so I do not have access to it.

EDIT: The problem here is that we need a KeyDeserializer which os not what is in the AddressModule. Maybe this should be added to all Akka serializers/deserializers?

Appreciate any pointers as I have been wrestling with this for more than a day.

TIA

Additional information. I missed the following error:

ERROR akka.serialization.jackson.JacksonObjectMapperProvider$ - Could not load configured Jackson module [concurrency.MyAkkaJacksonModule], please verify classpath dependencies or amend the configuration

Ok. So the configuration is being read correctly. Now looking for a way to set the path.

Anyone know how to do this from the project source?

TIA

Not a problem of the classpath. Changed MyAkkaJacksonModule from a case object to a case class and it seems to be working.

EDIT: Neglected to mention: I am using Dotty (Scala 3).