Java.lang.IllegalStateException: the parent was not null, but this component is not bound

I have the following exception while running the JSF program.

    org.apache.jasper.JasperException: An exception occurred processing JSP page /pages/general/internalServerErrorPage.jsp at line 44

    41:             <link rel="shortcut icon" href="<%=request.getContextPath()%>/resources/images/infomindzicon.ico" type="image/x-icon" />
    42:         </head>
    43:         <body id="sscmsMainBody">
    44:             <h:form id="internalServerErrorPageForm" binding="#{ServerErrorBean.initForm}">
    45:                 <rich:page id="richPage" theme="#{LayoutSkinBean.layoutTheme}"
    46:                            width="#{LayoutSkinBean.layoutScreenWidth}"
    47:                            sidebarWidth="0">
Caused by: javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Parent was not null, but this component not related
    at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
    at org.apache.jsp.pages.general.internalServerErrorPage_jsp._jspService(internalServerErrorPage_jsp.java:207)
    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:377)

What is the meaning of this exception and how can I solve it?


Refresh . My code is below

public HtmlForm getInitForm() {
    validateSession();
    return initForm;
}

Authentication method

private void validateSession() {        
    HttpSession session = null;
    try {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        actionPanelRendered = false;
        if (facesContext != null) {
            session = (HttpSession) facesContext.getExternalContext().getSession(false);            
            if (session != null) {
                if (session.getAttribute(SessionAttributes.USER_LOGIN_NAME.getName()) != null) {
                    actionPanelRendered = true;
                }
            }
        }
    } catch(Exception e) {
        logger.info("Exception arise in server error bean");
        e.printStackTrace();
    }
}
+3
source share
1 answer

So this comes from the following line:

<h:form id="internalServerErrorPageForm" binding="#{ServerErrorBean.initForm}">

You have attached the form to a bean for an unknown reason. An exception indicates that this component has a parent, but it is not actually a parent at all in the component tree on the JSP page. This, in turn, indicates that you are doing something like the following in a bean before or during a method call getInitForm():

form.setParent(someComponent);

, .


: , <f:view> HTML JSF.


2: , <h:form> bean. ( , , , . ).


, validateSession, EL :

rendered="#{not empty user.name}"

, SessionAttributes.USER_LOGIN_NAME user.

+5

Source: https://habr.com/ru/post/1783778/


All Articles