0
私はシンプルなjsfログインアプリケーションを持っています。サーブレットjspのServlet.service()が例外をスローしましたjava.lang.RuntimeException:FacesContextが見つかりません
私のlogin.jspが
<%@ page contentType="text/html"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<f:view>
<html>
<head>
<title>JSF Login Application</title>
</head>
<body>
<h:form>
<table>
<tr>
<td><h:outputText value="Enter Login ID: " /></td>
<td><h:inputText id="id" value="#{LoginBean.loginid}" /></td>
</tr>
<tr>
<td><h:outputText value="Enter Password: " /></td>
<td><h:inputSecret id="pwd" value="#{LoginBean.pwd}" /></td>
</tr>
<tr>
<td> </td>
<td><h:commandButton value="Login" action="#{LoginBean.CheckValidUser}" /></td>
</tr>
</table>
</h:form>
</body>
</html>
</f:view>
マイLoginBeanが
public class LoginBean{
String loginid;
String pwd;
public LoginBean(){}
public String getLoginid(){
return loginid;
}
public void setLoginid(String loginid){
this.loginid = loginid;
}
public String getPwd(){
return pwd;
}
public void setPwd(String pwd){
this.pwd = pwd;
}
public String CheckValidUser()
{
if(loginid.equals("username") && pwd.equals("password"))
{
return "success";
}
else
{
return "fail";
}
}
}
ですし、私のweb.xmlがbにあるようです
<web-app>
<display-name>JSFLoginAppln</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
です展開中に例外をスローしないため、展開中は問題ありません。しかし、私はJBOSSサーバ上で実行すると、それは次の例外
13:08:10,800 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
java.lang.RuntimeException: Cannot find FacesContext
at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1855)
at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1672)
at org.apache.jsp.login_jsp._jspx_meth_f_005fview_005f0(login_jsp.java:99)
at org.apache.jsp.login_jsp._jspService(login_jsp.java:76)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
をスロー誰もが....これを固定する際、事前に
おかげで私を助けてください!
LoginBeanをManagedBeanとしてマークするのを忘れましたか? –
http://stackoverflow.com/questions/5344797/java-lang-runtimeexception-cannot-find-facescontext-jsf-1-2-primefaces-tom –
@ Mr.J4mes:私はそれをマークしました。 <管理豆> \t \t <マネージド・ビーン名> LoginBeanマネージド・ビーン名> \t \t <マネージド・ビーンクラス> com.bean.LoginBeanマネージド・ビーンクラス> \t \t request managed-bean-scope> \t managed-bean> –
Hawks