在Login.class / Form上播放框架错误“RuntimeException:java.lang.reflect.InvocationTargetException”

时间:2017-03-27 19:28:16

标签: java playframework-2.0

我的应用程序已运行一个月了。截至今天,当我尝试登录时,我收到此错误: RuntimeException:java.lang.reflect.InvocationTargetException

它发生在我的Application.java控制器中: enter image description here

此代码来自Play Start App模板/种子。

这是Login类:

/**
 * Login class used by Login Form.
 */
public static class Login {

    @Constraints.Required
    public String email;
    String errMessage = "";

    @Constraints.Required
    public String password;

    /**
     * Validate the authentication.
     *
     * @return null if validation ok, string with details otherwise
     */
    public String validate() {
        Logger.debug("Login - validate()");
        User user = null;
        try {
            user = User.authenticate(email, password);
            SessionData createUserSession = AccessMiddleware.createUserSession(user);
            AuditLog.setLog(user.fullname, user.getEmail(), "Login", "validate()", "User authenticated",
                    user.fullname);

            // Let's setup the Workflow Session...              
            WorkflowUser workflowUser = WorkflowUser.initialize(email);
            WorkflowSessionData workflowCreateUserSession = WorkflowSessionAccess.createUserSession(workflowUser);

        } catch (AppException e) {
            errMessage = Messages.get("error.technical");
            return errMessage;
        }
        if (user == null) {
            errMessage = Messages.get("invalid.user.or.password");
            return errMessage;
        } else if (!user.validated) {
            errMessage = Messages.get("account.not.validated.check.mail");
            return errMessage;
        }
        return null;
    }

}

以下是身份验证功能:

/**
     * Handle login form submission.
     *
     * @return Dashboard if auth OK or login form if auth KO
     */
public Result authenticate() {
    String errorMessage = "";

    Form<Login> loginForm = form(Login.class).bindFromRequest();
    Logger.debug("authenticate");
    Form<Register> registerForm = form(Register.class);

    if (loginForm.hasErrors()) {
        Logger.debug("authenticate - bad request");
        // return badRequest(index.render(registerForm, loginForm));
        return badRequest(auth.render(loginForm));
        // return badRequest(index.render());
        // return badRequest();
    } else {
        Logger.debug("authenticate - good request");
        session("email", loginForm.get().email);

        boolean isAuth = AccessMiddleware.isAuthenticated();
        RoleType role = AccessMiddleware.getSessionRole();

        // Let's see if we need to redirect...
        String cardKey = openCardKey;
        if (cardKey != null) {
            if (!cardKey.equals("")) {
                // Let's redirect...
                // First remove the session variable...
                openCardKey = "";
                return redirect(routes.Application.openCard(cardKey));
            }
        }

        switch (role) {
        case USER:
            return GO_USER;

        case ADMIN:
            return GO_ADMIN;

        default:
            return GO_HOME;

        }
    }
}

我没有更改任何代码,这个错误刚刚开始。

我发现了一些帖子并尝试了解决方案,但仍然收到错误:

Playframework: [RuntimeException: java.lang.reflect.InvocationTargetException]

Playframework: InvocationTargetException

我在Eclipse中清理,刷新并重建了项目。我已删除目标文件夹并重新创建。我在项目中没有错误。

任何帮助都会很棒。

0 个答案:

没有答案