Java Mailing List Archive

http://www.junlu.com/

Home » users.myfaces »

Re: Problem with myfaces 2.1.7-SNAPSHOT (ClassCastException
during RV(1) )

Wojtek K

2012-03-20

Replies: Find Java Web Hosting

Author LoginPost Reply
Hello.

Now I am able to reproduce this stacktrace with small view.

layout.xhtml

 
 </h:head>

 <h:body>

   <h:form>
     <ui:insert name="page-content">

     </ui:insert>

   </h:form>

 </h:body>

</html>



sample.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:h="http://java.sun.com/jsf/html"
  >

  <ui:composition template="/templates/layout.xhtml">

   <ui:define name="page-content">

     <h:commandLink value="test link"/>

   </ui:define>
 </ui:composition>
</html>



bad_view.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:c="http://java.sun.com/jsp/jstl/core"
  xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core">

 <c:if test="#{request !=null}">
   <ui:include src="sample.xhtml"></ui:include>
 </c:if>

</html>

if yout type in browser localhost:8080/test/bad_view.xhtml and click test_link on page the error occurs.

If you remove <h:outputStylesheet library="css" name="test_css.css"/>  
from layout.xhtml problem dosen't occurs.

Another solution is to wrapp c:if tag with for example h:outputText and problem is gone too.

In our views there aren't any <h:outputStylesheet or h:outputScript tags but we have same stacktrace.

I have eliminated all views like bad_view.xhtml in our project but error still occurs.

I have no idea what is wrong :/

PS
bad_view.xhtml i correct in terms of using jsf?

wojtek


Dnia 20-03-2012 o godz. 17:05 Leonardo Uribe napisał(a):
> Hi
>
> I checked the stacktrace and the code looks good. There are not recent
> changes that could affect in that location.
>
> The issue should be caused by a listener that is not restored
> correctly. Take a look at your <f:event listener="..", @ListenerFor
> annotations. One suposition is you have registered a listener in a
> renderer using @ListenerFor or you have registered programatically a
> renderer as a listener, but the renderer does not belong to the same
> component and the restore code (see the line for restore renderer):
>
>           //Full restore
>           listenerCapability = (Integer) values[2];
>
>           if ((listenerCapability & LISTENER_TYPE_COMPONENT) != 0)
>           {
>              listener = UIComponent.getCurrentComponent(context);
>           }
>           else if ((listenerCapability & LISTENER_TYPE_RENDERER) != 0)
>           {
>              listener = (ComponentSystemEventListener)
>
> UIComponent.getCurrentComponent(context).getRenderer(context);
>           }
>           else
>           {
>              listener = (ComponentSystemEventListener)
>
> UIComponentBase.restoreAttachedState(context, values[1]);
>           }
>
> will cause a class cast exception. If that's the case, please let us
> know the use case to add the additional check and force save the
> renderer class in such cases. In other case, to solve this issue it is
> necessary provide a test case.
>
> regards,
>
> Leonardo Uribe
>
> 2012/3/20 Werner Punz <werner.punz@(protected)>:
> > Best bet is to file a bugreport to get this fixed asap.
> >
> > Werner
> >
> >
> > Am 19.03.12 22:14, schrieb Wojtek K:
> >
> >> Hello!
> >>
> >>
> >>
> >> Recently we switched from myfaces 2.1.6 to 2.1.7-SNAPSHOT (in 2.1.6 we
> >> have problems with ui:repeat).
> >>
> >>
> >>
> >> With 2.1.7-SNAPSHOT sometimes we see this stacktrace:
> >>
> >>
> >>
> >> Caused by: java.lang.ClassCastException:
> >> org.apache.myfaces.renderkit.html.HtmlTextRenderer cannot be cast to
> >> javax.faces.event.ComponentSystemEventListener
> >> at
> >> javax.faces.component.UIComponent$EventListenerWrapper.restoreState(UIComponent.java:1600)
> >> at
> >> javax.faces.component.UIComponentBase.restoreAttachedState (UIComponentBase.java:1878)
> >> at javax.faces.component._DeltaList.restoreState(_DeltaList.java:254)
> >> at
> >> javax.faces.component.UIComponentBase.restoreAttachedState (UIComponentBase.java:1878)
> >> at
> >> javax.faces.component.UIComponentBase.restoreFullSystemEventListenerClassMap (UIComponentBase.java:2181)
> >> at
> >> javax.faces.component.UIComponentBase.restoreState (UIComponentBase.java:2021)
> >> at javax.faces.component.UIOutput.restoreState (UIOutput.java:209)
> >> at
> >> javax.faces.component.UIComponentBase.processRestoreState (UIComponentBase.java:1593)
> >> at
> >> org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy$2.invokeContextCallback(DefaultFaceletsStateManagementStrategy.java:441)
> >> at
> >> javax.faces.component.UIComponent.invokeOnComponent (UIComponent.java:227)
> >> at
> >> javax.faces.component.UIComponentBase.invokeOnComponent (UIComponentBase.java:1136)
> >> at
> >> javax.faces.component.UIComponent.invokeOnComponent (UIComponent.java:238)
> >> at
> >> javax.faces.component.UIComponentBase.invokeOnComponent (UIComponentBase.java:1136)
> >>
> >>
> >>
> >> Our views are very complicated so i can't find what is wrong.
> >>
> >> Can this be bug in myfaces? or it is problem in ours views?
> >>
> >>
> >>
> >> web.xml
> >>
> >>
> >>
> >> <context-param>
> >>
> >> <param-name>org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE</param-name>
> >>         <param-value>true</param-value>
> >>     </context-param>
> >>
> >>     <context-param>
> >>
> >> <param-name>org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS</param-name>
> >>         <param-value>true</param-value>
> >>     </context-param>
> >>
> >>     <context-param>
> >>         <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
> >>         <param-value>true</param-value>
> >>     </context-param>
> >>
> >>
> >> thanks
> >>
> >>
> >>
> >> wojtek
> >>
> >>
> >>
> >
> >



©2008 junlu.com - Jax Systems, LLC, U.S.A.