I am attempting to move my application from 2.5.12 to 2.5.18, and then onto 2.6.x. I am using the MessagesApi
since I read that the old Message is deprecated.
I have a controller, Application.java
which I have set up the MessagesApi
and Messages
objects and receive no errors in compiling, but receive this error when attempting to run the application:
[error] application -
! @77h0ppgdc - Internal server error, for (GET) [/] ->
play.api.UnexpectedException: Unexpected exception[ExceptionInInitializerError: null]
at play.core.server.DevServerStart$$anon$1.$anonfun$get$3(DevServerStart.scala:187)
at scala.Option.map(Option.scala:146)
at play.core.server.DevServerStart$$anon$1.$anonfun$get$2(DevServerStart.scala:133)
at scala.util.Success.flatMap(Try.scala:247)
at play.core.server.DevServerStart$$anon$1.$anonfun$get$1(DevServerStart.scala:131)
at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:655)
at scala.util.Success.$anonfun$map$1(Try.scala:251)
at scala.util.Success.map(Try.scala:209)
at scala.concurrent.Future.$anonfun$map$1(Future.scala:289)
at scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)
Caused by: java.lang.ExceptionInInitializerError: null
at controllers.Application$$FastClassByGuice$$b5b6aa19.newInstance(<generated>)
at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:110)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268)
Caused by: java.lang.NullPointerException: null
at controllers.Application.<clinit>(Application.java:75)
at controllers.Application$$FastClassByGuice$$b5b6aa19.newInstance(<generated>)
at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:111)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:268)
at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:110)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:90)
The line that I am looking at:
at controllers.Application.<clinit>(Application.java:75)
Here is the snippet:
import play.i18n.Lang;
import play.i18n.Messages;
import play.i18n.MessagesApi;
public class Application extends Controller {
@Inject
MailerClient mailerClient;
@Inject
FormFactory formFactory;
@Inject
static MessagesApi messagesApi;
static Collection<Lang> candidates = Collections.singletonList(new Lang(Locale.US));
static Messages messages = messagesApi.preferred(candidates);
...
}
where in the Application.java
controller is:
static Messages messages = messagesApi.preferred(candidates);
I built the code based on this document:
https://www.playframework.com/documentation/2.6.x/JavaI18N#Externalizing-messages
I am not sure how to tackle this one. I appreciate the help.