当我尝试通过http://localhost/home/index.html访问我的开发网站时出现此错误,该网站重定向到http://localhost/home/views/main/index.xhtml:
java.io.FileNotFoundException: /views/main/index*.xhtml Not Found in ExternalContext as a Resource
我正在使用Tomcat 7.0.8,Mojarra JSF 2.0.4和Eclipse Helios。我已经检查了index.xhtml文件的WAR部署文件,它在WAR文件中。我还检查了../wtpwebapps/home/views/main目录,可以看到Eclipse已经部署了index.xhtml文件。
我得到的堆栈跟踪是:
07/02/2011 3:58:53 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/home] threw exception
java.lang.NullPointerException
at com.sun.faces.lifecycle.RestoreViewPhase.notifyAfter(RestoreViewPhase.java:301)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:114)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:383)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
我不知道为什么我会收到上述错误。有人可以帮忙吗?
答案 0 :(得分:1)
我不知道负责重定向的代码如何,但
/views/main/index*.xhtml
绝对看起来不对。那边的星号是什么?相应地修复代码,不再在视图ID中发出此星号。
答案 1 :(得分:1)
我解决了这个问题:这只是web.xml的配置问题。
我在web.xml中将webapp版本声明为2.0而不是Tomcat 7中的3.0。