Spring Web Flow integration causes ClassCastException

UI Components for JSF
Post Reply
CannyDuck
Posts: 36
Joined: 27 Apr 2010, 17:26

27 Apr 2010, 17:39

I try to use PrimeFaces in my Spring Web Flow project with Spring centric JSF integration.
If a use a componet that supports ajax functionality (e.g. a datatable wity dynamic loading) I get a ClassCastException during the ajax call is performed. The PrimeFaces AjaxHandler an ViewFactoryCreator are configured as written in the documentation. It seems that the PostRestoreViewHandler builds a partialView as aspected but the JSFView created an new UIViewRoot that cases the ClassCastException, because the PrimeFacesPhaseListener excepts a partialView.

Code: Select all

17:21:25,825 WARN  [ERROR] Handler execution resulted in exception
org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'transactionList' of flow 'transactionList'
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:569)
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
        at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:163)
        at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:530)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1219)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
        at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
        at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:67)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilt
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.concurrent.ConcurrentSessionFilter.doFilterHttp(ConcurrentSessionFilter.java:99)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at com.itc.commons.spring.web.security.filter.SessionTimeoutExposingFilter.doFilterHttp(SessionTimeoutExposingFilter.java:40)
        at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
        at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
        at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1190)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
        at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1190)
        at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:424)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
        at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:494)
        at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229)
        at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:931)
        at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:361)
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
        at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:867)
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245)
        at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
        at org.eclipse.jetty.server.Server.handle(Server.java:337)
        at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:581)
        at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1020)
        at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:775)
        at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:228)
        at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:417)
        at org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:474)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:437)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassCastException: javax.faces.component.UIViewRoot
        at org.primefaces.application.PrimeFacesPhaseListener.restorePartialView(PrimeFacesPhaseListener.java:162)
        at org.primefaces.application.PrimeFacesPhaseListener.beforePhase(PrimeFacesPhaseListener.java:70)
        at org.springframework.faces.webflow.JsfUtils.notifyBeforeListeners(JsfUtils.java:61)
        at org.primefaces.integration.swf.JSFViewWrapper.render(JSFViewWrapper.java:71)
        at org.springframework.webflow.engine.ViewState.render(ViewState.java:282)
        at org.springframework.webflow.engine.ViewState.resume(ViewState.java:207)
        at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
        at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
        ... 72 more
Thanks for your support.

CannyDuck
Posts: 36
Joined: 27 Apr 2010, 17:26

28 Apr 2010, 09:42

I found a temporary solution for that problem. The PrimeFaces integration ViewCreator just wraps the created View from the JSFViewCreator. During the creation of the View the JSFViewCreator calls the PostRestoreViewHandler as after PhaseListener that creates a PartialViewRoot that is set in the FacesContext. But the calling ViewCreator does not set the PartialViewRoot in the the created view. A quick fix ist to duplicate the getView(...) method of the JSFViewCreator and place it in the ViewCreator of PrimeFaces. Replace the return statement of the copied method with these to lines:

Before:

Code: Select all

return view;
After:

Code: Select all

view.setViewRoot(facesContext.getViewRoot());
return new JSFViewWrapper(view, context, lifecycle);
Should I create a ticket for that?

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests