使用Facelets 404错误页面时,Websphere会抛出FileNotFoundException,而不是调度到404错误页面

时间:2015-03-04 07:32:20

标签: jsf jsf-2 facelets custom-error-pages websphere-liberty

我正在尝试将Facelets页面定义为我的web.xml中的自定义404错误页面,如下所示:

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/javaee" 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-app_3_0.xsd"
         version="3.0">
...
 <welcome-file-list>
        <welcome-file>/index.xhtml</welcome-file>
    </welcome-file-list>
<error-page>
      <error-code>404</error-code>
      <location>/pageNotFound.xhtml</location>
</error-page>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
...
</web-app>

的Server.xml

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

    <!-- Enable features -->

<featureManager>
        <feature>jsp-2.2</feature> 
            <feature>ejbLite-3.1</feature> 
                <feature>jpa-2.0</feature> 
                <feature>jsf-2.0</feature> 
                <feature>cdi-1.0</feature> 
                <feature>localConnector-1.0</feature> 
                <feature>jaxws-2.2</feature> 
                <feature>jaxrs-1.1</feature> 
        </featureManager> 


    <httpEndpoint host="*" httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint"/> 

<applicationMonitor updateTrigger="mbean"/> 
    ...

</server>

现在,如果我部署到Websphere liberty profile 8.5.5.4并转到[app_root] / abc,我看不到我的自定义错误页面。相反,我看到服务器默认错误页面:

Error Message: java.io.FileNotFoundException: SRVE0190E: File not found: /abc
Error Code: 404
Target Servlet: com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor
Error Stack: 
java.io.FileNotFoundException: SRVE0190E: File not found: /abc 
     at com.ibm.ws.webcontainer.extension.DefaultExtensionProcessor.handleRequest(DefaultExtensionProcessor.java:528) 
     at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1101) 
     at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4797) 
     at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:297) 
     at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:981) 
     at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262) 
     at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:938) 
     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:745) 

这适用于我之前使用WildFly 8.2.0.final服务器的项目。当我使用JSP而不是Facelets页面尝试此操作时,它确实有效。

是否可以在Websphere liberty profile 8.5.5.4中将Facelets页面用作自定义错误页面?我是否需要在Websphere上进行更多配置?或者我在这里错过了什么?

0 个答案:

没有答案