Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Maven 无法访问目标,标识符';securityBean';已解析为空_Maven_Jsf_Jsf 2 - Fatal编程技术网

Maven 无法访问目标,标识符';securityBean';已解析为空

Maven 无法访问目标,标识符';securityBean';已解析为空,maven,jsf,jsf-2,Maven,Jsf,Jsf 2,嘿,我在jetty中运行应用程序时遇到了这个问题。 我使用spring框架和maven在java上创建了一些应用程序web 当我想尝试登录我的站点时,我遇到了一个错误 此错误日志来自jetty: javax.el.PropertyNotFoundException: /screens/login.xhtml @30,138 value="#{securityBean.userId}": Target Unreachable, identifier 'securityBean' resolved

嘿,我在jetty中运行应用程序时遇到了这个问题。 我使用spring框架和maven在java上创建了一些应用程序web

当我想尝试登录我的站点时,我遇到了一个错误

此错误日志来自jetty:

javax.el.PropertyNotFoundException: /screens/login.xhtml @30,138 value="#{securityBean.userId}": Target Unreachable, identifier 'securityBean' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:97)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:91)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1023)
at javax.faces.component.UIInput.validate(UIInput.java:953)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1204)
at javax.faces.component.UIInput.processValidators(UIInput.java:693)
at javax.faces.component.UIForm.processValidators(UIForm.java:240)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1081)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1081)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1159)
这是我的login.xhtml:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui">

<f:view contentType="text/html">

<h:head>
    <title>igate web admin</title>
    <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>

    <link type="text/css" rel="stylesheet" href="#{request.contextPath}/themes/bootstrap/bootstrap.css" />
    <link type="text/css" rel="stylesheet" href="#{request.contextPath}/themes/bootstrap/bootstrap.min.css" />
    <link type="text/css" rel="stylesheet" href="#{request.contextPath}/themes/bootstrap/bootstrap-theme.css" />
    <link type="text/css" rel="stylesheet" href="#{request.contextPath}/themes/bootstrap/bootstrap-theme.min.css" />
    <ui:insert name="head"></ui:insert>
</h:head>

<h:body>
    <div class="container">
        <h:form class="form-signin" role="form">
            <div class="logo"></div>
            <h2 class="form-signin-header" style="text-align: center; color: white"> LOGIN I-GATE</h2>
            <h:inputText class="form-control" required="true" requiredMessage="Username harus diisi" id="uname"  value="#{securityBean.userId}"/>
            <br></br>
            <h:inputSecret class="form-control" required="true" requiredMessage="Password harus diisi"  value="#{securityBean.password}"/>
            <button class="btn btn-lg btn-primary btn-block" type="submit" action="#{securityBean.login}" ajax="false">Sign in</button>
            <h4 style="text-align: center; color: white;">Please login with your Username and Password</h4>
        </h:form>
    </div>
</h:body>
}

我坚持这个问题。我试着采纳stackoverflow的另一个建议。但没有人能解决这个问题。请帮忙:)


谢谢

您使用哪种jsf实现?另外,您从@user3635731导入的
@ManagedBean
@SessionScoped
包是什么?您是否在项目中启用CDI?当我从SVN签出并为src:D构建路径时出错,然后类securityPage没有读取。。谢谢你的回答,朋友:D它已经解决了:)Stack Overflow是一个真正的问答网站,而不是一个老式的讨论论坛。一旦你解决了问题,就没有必要在标题中大喊“解决了!!”。只需发布一个真实的答案,并将其标记为已接受。它在列表中的显示将有所不同,并且在搜索中会特别针对它。我之前很抱歉,因为我不知道如何标记为已解决的问题,而不标记正确或错误的答案。抱歉之前:)
@ManagedBean( name="securityBean" )

@SessionScoped

public class SecurityPage {

private String userId;
private String password;

private UserDao userDao;
private Logger log = Logger.getLogger( SecurityPage.class );

public String getUserId() {
    return userId;
}

public void setUserId(String userId) {
    this.userId = userId;
}

public String getPassword() {
    return password;
}

public void setPassword(String password) {
    this.password = password;
}

/**
 * use to clear properties in this class
 * 
 */
private void clearPage() {

    this.userId = null;
    this.password = null;
}

/**
 * Executed to validate username and password
 * 
 * @return String
 */
public String login() {

    userDao = ( UserDao ) ServiceLocator.getService( "userDao" );

    try {

        String pass = Secure.digest( password );
        MUser user = userDao.login( userId, pass );

        if( user != null  ) {

            SessionUtil.setUserSession( user );
            SessionUtil.setObject( Constant.LOGIN_ROLENAME, user.getRoleName() );
        }
        else {

            FacesContext.getCurrentInstance().addMessage(
                "msgs",
                new FacesMessage( FacesMessage.SEVERITY_WARN,
                                  "User ID atau Password anda tidak valid.",
                                  "User ID atau Password anda tidak valid." ) );
                clearPage();

                return "login_failed";
        }
    } 
    catch( Exception e ) {

        FacesContext.getCurrentInstance().addMessage( 
                "msgs",
                new FacesMessage( FacesMessage.SEVERITY_WARN, 
                                  "User ID atau Password anda tidak valid.", 
                                  "User ID atau Password anda tidak valid." ) );
        clearPage();

        return "login_failed";
    }

    clearPage();

    return "login_success";
}

/**
 * Logout Action
 * 
 * Executed to invalidate session and logout user
 * 
 * @return String
 */
public String logout() {

    log.info( "user logout from application" );

    try {

        SessionUtil.invalidate();
    } 
    catch( Exception e ) {
        log.error( e );
    }

    return "/screens/login.jsf?faces-redirect=true";
}