Serialization error after disabling java serialization

I tried disabling Java serialization with below config. My cluster remoting is through netty tcp

#Disable Java serialization
akka.actor.allow-java-serialization = off
akka.actor.enable-additional-serialization-bindings = on

#enable this in local.conf (non production)
akka.actor.serialize-messages = on
akka.actor.serialize-creators = on

I am getting below stacktrace, I don’t want to put Java serialization back, any help appreciated.

[INFO] [10/27/2019 11:35:12.052] [main] [akka.cluster.Cluster(akka://test-akka-cluster)] Cluster Node [akka.tcp://test-akka-cluster@127.0.0.1:2551] - Starting up, Akka version [2.5.26] ...
[ERROR] [10/27/2019 11:35:12.069] [test-akka-cluster-akka.actor.default-dispatcher-2] [akka://test-akka-cluster/system/cluster] pre-creation serialization check failed at [akka://test-akka-cluster/system/cluster/core]
java.lang.IllegalArgumentException: pre-creation serialization check failed at [akka://test-akka-cluster/system/cluster/core]
	at akka.actor.dungeon.Children.makeChild(Children.scala:278)
	at akka.actor.dungeon.Children.actorOf(Children.scala:47)
	at akka.actor.dungeon.Children.actorOf$(Children.scala:46)
	at akka.actor.ActorCell.actorOf(ActorCell.scala:447)
	at akka.cluster.ClusterDaemon.createChildren(ClusterDaemon.scala:224)
	at akka.cluster.ClusterDaemon$$anonfun$receive$1.applyOrElse(ClusterDaemon.scala:233)
	at akka.actor.Actor.aroundReceive(Actor.scala:539)
	at akka.actor.Actor.aroundReceive$(Actor.scala:537)
	at akka.cluster.ClusterDaemon.aroundReceive(ClusterDaemon.scala:186)
	at akka.actor.ActorCell.receiveMessage(ActorCell.scala:612)
	at akka.actor.ActorCell.invoke(ActorCell.scala:581)
	at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:268)
	at akka.dispatch.Mailbox.run(Mailbox.scala:229)
	at akka.dispatch.Mailbox.exec(Mailbox.scala:241)
	at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
	at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
	at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
	at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.io.NotSerializableException: No configured serialization-bindings for class [akka.cluster.JoinConfigCompatChecker$$anon$1]
	at akka.serialization.Serialization.serializerFor(Serialization.scala:332)
	at akka.serialization.Serialization.findSerializerFor(Serialization.scala:307)
	at akka.actor.dungeon.Children.$anonfun$makeChild$1(Children.scala:271)
	at akka.actor.dungeon.Children.$anonfun$makeChild$1$adapted(Children.scala:267)
	at scala.collection.LinearSeqOptimized.forall(LinearSeqOptimized.scala:85)
	at scala.collection.LinearSeqOptimized.forall$(LinearSeqOptimized.scala:82)
	at scala.collection.immutable.List.forall(List.scala:89)
	at akka.actor.dungeon.Children.makeChild(Children.scala:267)

I’d recommend disabling akka.actor.serialize-creators = on, what it does is try to serialize all props used to start actors, but not all props were meant to be remotely deployed so props will never be sent to other nodes, in this case it is an internal cluster actor which will never be remotely deployed failing the serialization check.

akka.actor.serialize-messages = on has the same problem but for messages, so can also be problematic in that it will require that any message sent, even completely internal messages that are never sent across network must have a serializer or be marked with akka.actor.NoSerializationVerificationNeeded when that is enabled.

Thank you! Probably this has to be updated in the documentation

https://doc.akka.io/docs/akka/current/serialization.html

According to doc, it is ok to enable below properties in local for debugging
akka.actor.serialize-messages = on
akka.actor.serialize-creators = on

Yes that could probably be clarified. A test that starts cluster can probably not be considered local, so just running your local tests without cluster (akka.provider = local) should let you enable those test settings without problems.

As a side note, in the long run we’ll probably want to provide a serialization testkit for verifying messages more explicitly. Moving forward with the typed APIs in 2.6 there is no way to do remote deploy, so that we will probably leave as it is for the “classic” actor API.

1 Like

Hi @johanandren ,
I’m facing a similar error with akka version 2.4.1.

                warn-about-java-serializer-usage = true
		enable-additional-serialization-bindings = on
		serialize-messages = on
		serializers {
        		proto = "akka.remote.serialization.ProtobufSerializer"
        	}
		serialization-bindings {
		  "java.io.serializable" = none
		  "com.google.protobuf.Message" = proto
			}

2023-03-27T11:43:13Z ERROR [antelope-akka.actor.default-dispatcher-2] c.e.e.antelope.actors.ProtobufMapper - swallowing exception during message send
java.io.NotSerializableException: No configured serialization-bindings for class [com.ea.eadp.antelope.protocol.models.rtm.LoginV3ResponseModel]
at akka.serialization.Serialization.serializerFor(Serialization.scala:172)
at akka.serialization.Serialization.findSerializerFor(Serialization.scala:151)
at akka.actor.dungeon.Dispatch$class.sendMessage(Dispatch.scala:121)
at akka.actor.ActorCell.sendMessage(ActorCell.scala:374)
at akka.actor.Cell$class.sendMessage(ActorCell.scala:295)
at akka.actor.ActorCell.sendMessage(ActorCell.scala:374)
at akka.actor.LocalActorRef.$bang(ActorRef.scala:402)
at akka.actor.ActorRef.tell(ActorRef.scala:126)
at com.ea.eadp.antelope.actors.ClientCoordinator.sendMessageToClient(ClientCoordinator.java:2222)
at com.ea.eadp.antelope.actors.ClientCoordinator.handleSessionManagerResult(ClientCoordinator.java:1790)
at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:26)
at akka.japi.pf.UnitCaseStatement.apply(CaseStatements.scala:21)
at scala.PartialFunction$class.applyOrElse(PartialFunction.scala:123)
at akka.japi.pf.UnitCaseStatement.applyOrElse(CaseStatements.scala:21)
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:170)
at scala.PartialFunction$OrElse.applyOrElse(PartialFunction.scala:171)
at akka.actor.Actor$class.aroundReceive(Actor.scala:480)
at akka.actor.AbstractActor.aroundReceive(AbstractActor.scala:47)
at com.ea.eadp.antelope.actors.AbstractInstrumentedActor.aroundReceive(AbstractInstrumentedActor.java:40)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
at akka.actor.ActorCell.invoke(ActorCell.scala:495)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
at akka.dispatch.Mailbox.run(Mailbox.scala:224)
at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

any help appreciated.

This describes what is wrong. You can read more about how you configure serialization in the the docs here: Serialization • Akka Documentation