In my local pc i run play 2.6 and i can´t get a single error. But in deployment as a service i get this error:
[Error] from application in application-akka.actor.default-dispatcher-11 - Error while handling error
java.lang.RuntimeException: No CSRF token was generated for this request! Is the CSRF filter installed?
or
internal server error, for (POST) [/methodName?csrfToken=token value] ->play.api.UnexpectedException: Unexpected exception[RuntimeException: No CSRF token was generated for this request! Is the CSRF filter installed?]
route code:
POST /methodName controllers.MyController.methodName()
Controller code:
public Result methodName() {
Form myClassForm = formFactory.form(MyClassForm.class).bindFromRequest();
if (myClassForm.hasErrors()) {
return badRequest(myClassForm.errorsAsJson());
} else {
session().clear();
session("email", myClassForm.get().email);
ObjectNode result = Json.newObject();
result.put("Success", "Sucesso");
return ok(result);
}
}
View code:
@import models.forms.MyClass
@import views.html.templates.fieldTemplate
@(MyClassForm: Form[MyClass])
@import helper._
@implicitField = @{ FieldConstructor(fieldTemplate.render)}
@form(action = helper.CSRF(routes.MyController.methodName()), 'id -> “formMyClass”) {