2012-03-04 65 views
2

我想設置一個簡單的JSF項目w/eclipse & maven。但我堅持d: 每當我嘗試運行我的東西,我得到這個錯誤:與eclipse,maven&glassfish的JSF - 錯誤:com.sun.faces.context.FacesFileNotFoundException

com.sun.faces.context.FacesFileNotFoundException 
at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:232) 
at com.sun.faces.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:273) 
at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:209) 
at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:114) 
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:230) 
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) 
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:113) 
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) 
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409) 
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534) 
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) 
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) 
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) 
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) 
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) 
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) 
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326) 
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227) 
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170) 
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) 
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) 
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) 
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) 
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) 
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) 
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) 
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) 
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) 
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) 
at com.sun.grizzly.ContextTask.run(ContextTask.java:71) 
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) 
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) 
at java.lang.Thread.run(Thread.java:722) 

我知道這是我的錯......我用無法找到它。 我只有一個web.xml,(空)faces-config.xml和一個hello.xhtml,我想要顯示。所有文件都在src/main/webapp/WEB-INF。 請幫助:)

以下是文件:

的web.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
id="WebApp_ID" version="2.5"> 
<display-name>Hello</display-name> 
<!-- Change to "Production" when you are ready to deploy --> 
<context-param> 
    <param-name>javax.faces.PROJECT_STAGE</param-name> 
    <param-value>Development</param-value> 
</context-param> 
<context-param> 
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name> 
    <param-value>.xhtml</param-value> 
</context-param> 
<context-param> 
    <param-name>primefaces.THEME</param-name> 
    <param-value>cupertino</param-value> 
</context-param> 
<!-- Welcome page --> 
<welcome-file-list> 
    <welcome-file>hello.xhtml</welcome-file> 
</welcome-file-list> 
<!-- JSF mapping --> 
<servlet> 
    <servlet-name>Faces Servlet</servlet-name> 
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
</servlet> 
<!-- Map these files with JSF --> 
<servlet-mapping> 
    <servlet-name>Faces Servlet</servlet-name> 
    <url-pattern>*.xhtml</url-pattern> 
</servlet-mapping> 

我faces-config.xml中:

<?xml version="1.0"?> 
<faces-config version="2.0" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xi="http://www.w3.org/2001/XInclude" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"> 
</faces-config> 

問候。 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:f="http://java.sun.com/jsf/core" 
    xmlns:h="http://java.sun.com/jsf/html"> 
<h:head> 
    <title>JSF 2.0 Hello World</title> 
</h:head> 
<h:body> 
    <h3>JSF 2.0 Hello World Example - hello.xhtml</h3> 
    <h:form> 
     <h:inputText value="#{helloBean.name}"></h:inputText> 
     <h:commandButton value="Welcome Me" action="welcome"></h:commandButton> 
    </h:form> 
</h:body> 
</html> 

asd

回答

3

不要把hello.xhtml放在WEB-INF中。只有配置文件必須去那裏。將hello.xhtml放入WEB-INF所在的目錄中。

+0

愚蠢的我!我以爲我試過這個,但顯然我沒有。當然完全是這樣 - 謝謝! – sne11ius 2012-03-04 09:10:46

+0

...以及不應公開打開的模板文件。相關:http://stackoverflow.com/questions/9031811/which-xhtml-files-do-i-need-to-put-in-web-inf-and-which-not – BalusC 2012-03-04 18:07:12