3

我正在使用 Spring Webflow 和 JSF 开发一个项目。我正在尝试完成类似于 Spring Webflow https://github.com/SpringSource/spring-webflow-samples/tree/master/booking-faces的预订面孔示例的事情。尝试执行网络流时出现以下错误。

org/apache/myfaces/renderkit/StateCacheUtils

viewId=/WEB-INF/flows/main/enterSearchCriteria.xhtml
location=C:\Users\workspace4\.metadata\.plugins\org.eclipse.wst.server.core  \tmp1\wtpwebapps\myWebApp\WEB-INF\flows\main\enterSearchCriteria.xhtml
phaseId=RENDER_RESPONSE(6)

Caused by:
java.lang.ClassNotFoundException - org.apache.myfaces.renderkit.StateCacheUtils
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)

完整的堆栈跟踪是:

java.lang.NoClassDefFoundError: org/apache/myfaces/renderkit/StateCacheUtils
    at org.springframework.faces.webflow.MyFacesFlowResponseStateManager.getWrappedMyfacesResponseStateManager(MyFacesFlowResponseStateManager.java:66)
    at org.springframework.faces.webflow.MyFacesFlowResponseStateManager.isWriteStateAfterRenderViewRequired(MyFacesFlowResponseStateManager.java:70)
    at org.apache.myfaces.application.ViewHandlerImpl.setWritingState(ViewHandlerImpl.java:371)
    at org.apache.myfaces.application.ViewHandlerImpl.writeState(ViewHandlerImpl.java:315)
    at javax.faces.application.ViewHandlerWrapper.writeState(ViewHandlerWrapper.java:65)
    at org.apache.myfaces.shared.renderkit.html.HtmlFormRendererBase.encodeEnd(HtmlFormRendererBase.java:220)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:63)
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:47)
    at org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:202)
    at org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:119)
    at org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:56)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:545)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1981)
    at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59)
    at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:116)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
    at org.springframework.faces.support.LifecycleWrapper.render(LifecycleWrapper.java:54)
    at org.springframework.faces.webflow.JsfView.render(JsfView.java:87)
    at org.springframework.webflow.engine.ViewState.render(ViewState.java:293)
    at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:242)
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:220)
    at org.springframework.webflow.engine.Flow.resume(Flow.java:537)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
    at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
    at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:227)
    at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:46)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:920)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:816)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:801)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    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.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    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:224)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
    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:100)
    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:405)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
    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)
Caused by: java.lang.ClassNotFoundException: org.apache.myfaces.renderkit.StateCacheUtils
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    ... 86 more

我检查了 stackoverflow 帖子的答案:java.lang.ClassNotFoundException: org.apache.myfaces.webapp.StartupServletContextListener。但是我使用的是 Maven 并且没有 /WEB-INF/lib 目录。我通过 Maven 依赖项在我的类路径上有 JSF 依赖项。不确定,这是怎么回事。谢谢

4

2 回答 2

2

MyFaces 在 2.1.10 版本中重新打包了 StateCacheUtils。所以 spring-webflow 不适用于 myfaces 2.1.10 或更高版本。

为此,我在 jira中创建了一个问题。也许它将在进一步的版本中得到修复。

同时,这个问题有一个非常非常非常丑陋的解决方法:

在您自己的项目中创建一个类 org.apache.myfaces.rederkit.StateCacheUtils 并让它从新位置继承,并取消以下代码:

package org.apache.myfaces.renderkit;

public class StateCacheUtils extends org.apache.myfaces.application.viewstate.StateCacheUtils {

}
于 2014-06-24T07:29:13.477 回答
0

截至去年年底(2012 年),StateCacheUtils 似乎已移至新包,现在位于 org.apache.myfaces.application.viewstate 下。它看起来像是 Spring Webflow 和 MyFaces 之间的依赖问题。您可能想在 Spring Weblflow 论坛上提出这个问题。

于 2013-05-20T05:15:16.220 回答