本文介绍了“目标不可到达,标识符'authenticator'解析为空"在SEAM中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在使用身份验证器类jboss-seam-2.2.0.GA来验证登录过程.输入用户名和密码并提交页面后,我的日志中出现以下错误消息:

I am using jboss-seam-2.2.0.GA, authenticator class to authenticate the login process. When I enter the username and password and submit the page, I am getting following error message in my logs:


application E javax.el.PropertyNotFoundException: /login.xhtml @27,76 action="#{authenticator.login()}": Target Unreachable, identifier 'authenticator' resolved to null
 javax.faces.el.EvaluationException: javax.el.PropertyNotFoundException: /login.xhtml @27,76 action="#{authenticator.login()}": Target Unreachable, identifier 'authenticator' resolved to null
 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
 at javax.faces.component.UICommand.broadcast(UICommand.java:387)

以下是代码:

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich" template="layout/noMenuTemplate.xhtml">
<ui:define name="body">
    <div id="content">
                <h:form id="loginForm">
        <rich:panel>
            <f:facet name="header">Login</f:facet>
            <h:messages />
<div class="dialog"><h:panelGrid columns="2" rowClasses="prop"
                columnClasses="name,value">
                <h:outputLabel for="username">Username</h:outputLabel>
                <h:inputText id="username" value="#{credentials.username}"
                    style="width: 150px;" />
                <h:outputLabel for="password">Password</h:outputLabel>
                <h:inputSecret id="password" value="#{credentials.password}"
                    style="width: 150px;" />
            </h:panelGrid></div>

            <div class="actionButtons"><h:commandButton id="submit"
                styleClass="button" value="Login" action="#{authenticator.login()}" /></div>
        </rich:panel>
        </h:form>
           </div>
</ui:define>
</ui:composition>

Authenticator.java

@Name("authenticator")
@AutoCreate
public class Authenticator {
    @Logger Log log;
    @In Identity identity;
    @In Credentials credentials;
    @In Session hibernateSession;

    public Authenticator() {}

    public void login() throws IOException {
        log.debug("calling login method ............... ");

        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();

        StringBuffer location = new StringBuffer(request.getContextPath());
        location.append("/j_security_check?j_username=");
        location.append((credentials.getUsername() != null) ? credentials.getUsername() : "");
        location.append("&j_password=");
        location.append((credentials.getPassword() != null) ? credentials.getPassword() : "");

        log.debug("LOCATION : " + location.toString());

        HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
        response.sendRedirect(response.encodeRedirectURL(location.toString()));
    }
}

推荐答案

您的Authenticator类似乎已正确实现.我会在您的日志中进一步搜索,以找出未创建它的原因.

Your Authenticator class appears to be implemented correctly. I'd search further up in your logs and find out why it isn't being created.

此外,我建议从components.xml发布相关部分.应该是这样的:

Also, I'd suggest posting the relevant section from components.xml. Should be something like:

<security:identity authenticate-method="#{authenticator.login}"/>

这篇关于“目标不可到达,标识符'authenticator'解析为空"在SEAM中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 17:45