javax.faces.application.Application.getResourceHandler上的java.lang.UnsupportedOperationException

时间:2013-02-12 10:53:33

标签: jsf

我正在使用Hibernate,Spring和JSF开展Web项目。当我运行项目时,我得到以下异常:

Servlet.service() for servlet Faces Servlet threw exception
java.lang.UnsupportedOperationException
    at javax.faces.application.Application.getResourceHandler(Application.java:286)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:307)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    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.core.StandardHostValve.invoke(StandardHostValve.java:168)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
    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:987)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

这是如何引起的?如何解决?

1 个答案:

答案 0 :(得分:4)

导致此问题是因为运行时类路径中缺少适用于JSF API的JSF实现。解决方案是将JSF实现JAR文件放在运行时类路径中。

换句话说,您有一个/WEB-INF/lib/jsf-api.jar文件,但不是/WEB-INF/lib/jsf-impl.jar文件,至少不是与JSF API JAR文件相同的版本。您需要确保提供一个,至少是正确的版本。