web-dev-qa-db-fra.com

java.lang.ClassCastException: com.Sun.faces.facelets.compiler.UIInstructions ne peut pas être converti en org.primefaces.model.menu.MenuElement

Ce matin, je suis entré dans mon bureau et la première chose que j'ai vue: le site de mon entreprise s'est écrasé. A cause de moi je pense.

Maintenant, j'ai essayé pendant une heure et demie de résoudre ce problème, mais je n'ai rien trouvé et tout le monde perd la raison, car le site Web ne fonctionne pas et je ne peux pas le réparer (je suis seul. Les créateurs du site sont partis ou en vacances). J'espère que vous pourrez m'aider!

Je reçois cette exception lorsque j'appelle le tableau de bord.xhtml de mon site Web.

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

Mon problème est: dans l'ensemble, il n'y a nulle part un fichier que j'ai créé moi-même. Donc, je ne sais vraiment pas où est exactement mon erreur. 

Pouvez-vous m'aider?

Voici quelques informations supplémentaires:

Toute 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)

fichier dashborad entier:

<!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>
17
user1713847

Un rapide google du message d'erreur montre

PanelMenu ne peut pas être rendu quand ses sous-éléments contiennent des commentaires. une boîte de dialogue d'alerte html s'affichera sur laquelle sera écrite "UI Layout Initialization Error ..." et sur le serveur une exception sera levée "L'exception Java.lang.ClassCast: com.Sun.faces.facelets.compiler.UIInstructions Ne peut pas être convertie en org.primefaces.model.menu.MenuElement".

17
Scary Wombat

Ajoutez simplement ceci à votre web.xml:

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

Les commentaires de votre JSF seront ignorés lors du rendu.

34
Michael

Ajoutez simplement ceci à votre web.xml:

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

Il ignorera les commentaires dans votre fichier JSF lors du rendu.

À partir de JSF1025, facelets.SKIP_COMMENTS était obsolète

9
user1553728

S'il vous plaît essayez de définir les éléments suivants:

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