Java JSF+;Openshift重定向不工作

Java JSF+;Openshift重定向不工作,java,jsf,jsf-2,Java,Jsf,Jsf 2,我正在用JSF2OpenShift(JBoss7服务器)做一个项目,我无法通过Bean重定向来解决问题。我在本地用玻璃鱼尝试一切。当我尝试访问“access.xhtml”页面时,出现了我的问题,为了监视已登录的用户,我放置了以下内容: <f:metadata> <f:event type="preRenderView" listener="#{sesion.checkSession()}" /> </f:metadata> 证明什么是回报 faceC

我正在用JSF2OpenShift(JBoss7服务器)做一个项目,我无法通过Bean重定向来解决问题。我在本地用玻璃鱼尝试一切。当我尝试访问“access.xhtml”页面时,出现了我的问题,为了监视已登录的用户,我放置了以下内容:

<f:metadata>
    <f:event type="preRenderView" listener="#{sesion.checkSession()}" />
</f:metadata>
证明什么是回报

faceContext.getExternalContext().getRequestContextPath()
我注意到它始终是“”,这向我表明重定向应该转到根目录。关键是,当我尝试直接进入www.my-app.rhcloud.com/access.xhtml时,总是抛出500个错误

Exception when handling error trying to reset the response.: java.lang.IllegalStateException
at com.sun.faces.context.ExternalContextImpl.redirect(ExternalContextImpl...
at org.sindicatopygp.beans.SessionBean.checkSession(SessionBean.java:43)

有什么想法吗?我们感谢我解决了这个问题。由于某些原因,如果重定向到servlet根目录并成功重定向到文件index.xhtml,index.xhtml将无法识别该文件。解决方案

public void checkSession() throws IOException{
    if(httpServletRequest.getSession().getAttribute("connected")==null)
    {
        try {
            faceContext.getExternalContext().redirect("/index.xhtml"); //For logged users
        } catch (Exception e) {
            try {
                faceContext.getExternalContext().redirect("/"); //For external visitors
            } catch (Exception ex) {
                //For other problems...
            }
        }
    }
}

确切的完整消息标题是什么?是否仅在处理试图重置响应的错误时出现异常。:java.lang.IllegalStateException?完整异常太大了,我想这个异常一定是问题所在。其他人则是冈萨罗·门多萨(Gonzalo Mendoza)的总统候选人
public void checkSession() throws IOException{
    if(httpServletRequest.getSession().getAttribute("connected")==null)
    {
        try {
            faceContext.getExternalContext().redirect("/index.xhtml"); //For logged users
        } catch (Exception e) {
            try {
                faceContext.getExternalContext().redirect("/"); //For external visitors
            } catch (Exception ex) {
                //For other problems...
            }
        }
    }
}