Akka and migrating from Java 8 Java 11: cannot use non-static local Creator to create actors; make it static


(Raman) #1

I am migrating an application from Java 8 to Java 11.
I compiled my app with Java 11 and ran it in VM with Java 11.
The Akka verison is 2.3.15.

When I run my app in Java 11 environment, I see the following exception at runtime:
java.lang.IllegalArgumentException: cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level
at akka.actor.Props$.create(Props.scala:112) ~[akka-actor_2.11-2.3.15.jar:?]
at akka.actor.Props.create(Props.scala) ~[akka-actor_2.11-2.3.15.jar:?]

I also tried compiling with Java 8 and running in Java 11 environment, I see the same exception.
Does it have something to do with using Java 11? Do I have to upgrade the Akka version?


(Patrik Nordwall) #2

You have to use 2.5.19 (or later), and also change to the _2.12 (scala) version of the artifacts.


(Raman) #3

Thanks Patrik. Upgrading to 2.12_2.5.19 helped.
To resolve the exception that I pasted above in the question, I had to resolve the following warning:
warning: [deprecation] create(Creator) in Props has been deprecated
return Props.create(new Creator() {
^
where T is a type-variable:
T extends Actor declared in method create(Creator)

Not resolving the above warning was throwing a runtime exception.