faces-config导致启动Web应用程序出现异常

时间:2012-04-23 18:14:50

标签: java jsf-2 tomcat6 faces-config

我正在开发一个Web应用程序。我在tomcat 6上使用JSF 2。 一切都很顺利,但现在我想浏览我的页面...(I decided to do an XML-less JSF Navigation approach)。为此,我需要添加faces-config.xml。我做到了,但是在添加了faces-config后,当我想打开我的页面时,我总是会遇到错误。

    SCHWERWIEGEND: Servlet.service() for servlet Faces Servlet threw exception
    java.lang.StackOverflowError
        at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)
...

如果我删除faces-config,一切都很好(但后来我没有导航:()。

以下是我的maven依赖项: com.sun.faces jsf-api 2.1.2 com.sun.faces jsf-impl 2.1.2 javax.servlet jstl 1.2 javax.servlet.jsp jsp-api 2.2 org.glassfish.web el-impl 2.2

这是我的faces-config.xml

<?xml version="1.0" encoding="utf-8"?>
<faces-config version="1.2" 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_1_2.xsd">

    <application>
        <navigation-handler>de.xxx.jsf.client.navigation.XXXNavigationHandler</navigation-handler>
    </application>
</faces-config>

这是我的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>JavaServerFaces</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>com.sun.faces.injectionProvider</param-name>
        <param-value>de.xxx.jsf.client.guice.GuiceInjectionProvider</param-value>
    </context-param>

    <!-- Welcome page -->
    <welcome-file-list>
        <welcome-file>faces/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>/faces/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

</web-app>

你们有谁知道应用程序崩溃的原因吗?

提前谢谢!

TJ

1 个答案:

答案 0 :(得分:2)

您的faces-config.xml标头仍然指向1.2 DTD。这可能会导致不可预测的错误。我建议将其更新为2.0 DTD并尝试。

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

<faces-config version="2.0"
   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-facesconfig_2_0.xsd">