2012-04-30 38 views
0

我正在使用jboss-seam-2.2.0.GA,認證者類來認證登錄過程。當我輸入用戶名和密碼,並提交頁面,我在我的日誌越來越以下錯誤信息:「目標不可到達,標識符'認證者'解析爲空」在SEAM中

 
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()));  
    } 
} 

回答

0

您的Authenticator類似乎正確實現。我會在日誌中進一步搜索並找出它未被創建的原因。

另外,我建議發佈components.xml中的相關部分。應該是這樣的:

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

<安全:身份驗證 - 法= 「#{} authenticator.authenticate」 記住,我= 「真」 與JAAS配置名稱= 「mylogin」/> – Manohar

+0

,在components.xml ,你告訴它調用'#{authenticator.authenticate}',但是你的Authenticator類沒有'authenticate()'方法。嘗試將其更改爲'#{authenticator.login}' –

相關問題