java.lang.ClassCastException: com.sun.faces.facelets.compiler.UIInstructions cannot be cast to org.primefaces.model.menu.MenuElement

心不动则不痛 提交于 2019-12-03 08:03:58

问题


This morning I came in to my office and the first thing I saw: my company site crashed. Because of me I think.

Now I tried for one hour and a half to fix this, but I found nothing and everybody looses their mind because the website doesn't work and I can't fix it (i'm alone. The creators of the site are gone or in holidays). So I hope you can help me out!

I get this exception, when I call the dashboard.xhtml of my website.

java.lang.ClassCastException: com.sun.faces.facelets.compiler.UIInstructions cannot be cast to org.primefaces.model.menu.MenuElement

My problem is: in the whole exception, nowhere is a file which I done by myself. So I really don't know where exactly my error is.

Can you help me?

Here are some additional informations:

Whole exception:

SEVERE: Error Rendering View[/WEB-INF/flows/dashboard/dashboard.xhtml]
java.lang.ClassCastException: com.sun.faces.facelets.compiler.UIInstructions cannot be cast to org.primefaces.model.menu.MenuElement
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeElements(TieredMenuRenderer.java:97)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeSubmenu(TieredMenuRenderer.java:162)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeElements(TieredMenuRenderer.java:119)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeMenu(TieredMenuRenderer.java:78)
at org.primefaces.component.menubar.MenubarRenderer.encodeMarkup(MenubarRenderer.java:49)
at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:105)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at org.springframework.faces.webflow.FlowViewHandler.renderView(FlowViewHandler.java:99)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at org.springframework.faces.webflow.FlowLifecycle.render(FlowLifecycle.java:80)
at org.springframework.faces.webflow.JsfView.render(JsfView.java:89)
at org.springframework.webflow.engine.ViewState.render(ViewState.java:296)
at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:243)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:221)
at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:116)
at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:101)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:182)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:323)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:173)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)

whole dashborad file:

<!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:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core" template="../../layouts/100.xhtml">

    <ui:define name="heading">
        <h:outputText value="Dashboard" />
    </ui:define>

    <ui:define name="caption">
        <p>List of all your configurations and enabled containers.</p>
    </ui:define>

    <ui:define name="main">
        <div id="main">

            <div class="page_margins">
                <div class="page">
                    <h:form id="form">
                        <p:panel header="Meine Projekte" rendered="#{personManagementBean.loggedIn}">

                            <p:growl id="msgs" showDetail="true" />

                            <p:dataTable id="ownerProjects" var="p" value="#{projectManagementBean.ownerProjects}" tableStyle="width:100%" emptyMessage="Keine Projekte vorhanden">

                                <p:column headerText="Projektk&uuml;rzel" style="width:100px">
                                    <h:outputText value="#{p.projectId}" />
                                </p:column>

                                <p:column headerText="Dom&auml;ne" style="width:80px">
                                    <h:outputText value="#{p.domain}" />
                                </p:column>
                                <p:column headerText="Sub-Dom&auml;ne" style="width:80px">
                                    <h:outputText value="#{p.subDomain}" />
                                </p:column>

                                <p:column headerText="Beschreibung">
                                    <h:outputText value="#{p.description}" />
                                </p:column>

                                <p:column style="width:40px">
                                    <p:panelGrid columns="2" styleClass="no-column-borders" cellpadding="2">
                                        <p:commandButton id="selectButton" update=":form:display" oncomplete="projectDialog.show()" icon="ui-icon-search" title="Anzeigen"
                                            actionListener="#{projectManagementBean.loadProject(p.projectId)}">
                                        </p:commandButton>
                                        <p:commandButton id="editButton" update=":form:display" icon="ui-icon-pencil" title="Anpassen" oncomplete="editProjectDialog.show()"
                                            actionListener="#{projectManagementBean.loadProject(p.projectId)}">
                                        </p:commandButton>
                                    </p:panelGrid>
                                </p:column>
                            </p:dataTable>

                        </p:panel>

                        <p:panel header="Meine Entwicklungsprojekte" rendered="#{personManagementBean.loggedIn}" style="margin-top:10px">

                            <p:dataTable id="developperProjects" var="p" value="#{projectManagementBean.developperProjects}" rendered="#{personManagementBean.loggedIn}" tableStyle="width:100%"
                                emptyMessage="Keine Projekte vorhanden">

                                <p:column headerText="Projektk&uuml;rzel" style="width:100px">
                                    <h:outputText value="#{p.projectId}" />
                                </p:column>

                                <p:column headerText="Dom&auml;ne" style="width:80px">
                                    <h:outputText value="#{p.domain}" />
                                </p:column>
                                <p:column headerText="Sub-Dom&auml;ne" style="width:80px">
                                    <h:outputText value="#{p.subDomain}" />
                                </p:column>

                                <p:column headerText="Beschreibung">
                                    <h:outputText value="#{p.description}" />
                                </p:column>

                                <p:column style="width:40px">
                                    <p:panelGrid columns="3" styleClass="no-column-borders" cellpadding="2">
                                        <p:commandButton id="selectButton" update=":form:display" oncomplete="projectDialog.show()" icon="ui-icon-search" title="Anzeigen"
                                            actionListener="#{projectManagementBean.loadProject(p.projectId)}">
                                        </p:commandButton>
                                    </p:panelGrid>
                                </p:column>
                            </p:dataTable>
                        </p:panel>

                        <ui:include src="./project/details.xhtml" />
                        <ui:include src="./project/editdetails.xhtml" />
                    </h:form>
                </div>
            </div>
        </div>
    </ui:define>

</ui:composition>

回答1:


A quick google of the error message shows

PanelMenu can't be rendered when it's sub elements contain comments. a html alert dialog will be shown on which written "UI Layout Initialization Error..." and on the server an exception is thrown "java.lang.ClassCastException:com.sun.faces.facelets.compiler.UIInstructions cannot be cast to org.primefaces.model.menu.MenuElement".




回答2:


Just add this to your web.xml:

<context-param>
   <param-name>facelets.SKIP_COMMENTS</param-name>
   <param-value>true</param-value>
</context-param>

It will skip the comments in your JSF while rendering.




回答3:


Just add this to your web.xml:

<context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
</context-param>

It will skip the comments in your JSF while rendering.

As of JSF1025, facelets.SKIP_COMMENTS has been deprecated.




回答4:


Please try setting the following:

<context-param>  
    <param-name>primefaces.THEME</param-name>  
    <param-value>blitzer</param-value>  
</context-param>


来源:https://stackoverflow.com/questions/20188092/java-lang-classcastexception-com-sun-faces-facelets-compiler-uiinstructions-can

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!