I am trying to create a simple login based on the example of Zentask - zentask - playframework , however, when I click on the login button that invokes the Application.authenticate action, it gives a runtime exception. I marked a line with an error
[RuntimeException: java.lang.reflect.InvocationTargetException]
Application.java
public class Application extends Controller { ......... public static class Login { public String email; public String password; public String validate() { if (User.authenticate(email, password) == null) { return "Invalid user or password"; } return null; } } public static Result authenticate() { Form<Login> loginForm = form(Login.class).bindFromRequest();
I understand that this has something to do with the validate function in the input class, because when I delete the call to the User.authenticate function in the validation function, it works without errors. But I canβt understand it.
User Class -
@Entity public class User extends Model { @Id @Constraints.Required @Formats.NonEmpty public String userId; @OneToOne(cascade=CascadeType.PERSIST) AccountDetails accDetails; public static Model.Finder<String,User> find = new Model.Finder<String,User>(String.class, User.class);
and class AccountDetails -
@Entity public class AccountDetails extends Model { @Id String userId; @Constraints.Required String emailId; @Constraints.Required String password; public static Model.Finder<String,AccountDetails> find = new Model.Finder<String,AccountDetails>(String.class, AccountDetails.class); public static AccountDetails authenticate(String email, String password) { return find.where() .eq("email", email) .eq("password", password) .findUnique(); } }
Any help would be greatly appreciated.
Thanx a lot.
ac-lap
source share