0

I'm developing a web application at the moment. I'm using JSF 2 on a tomcat 6. Everything went great, but now I want to navigate through my pages... (I decided to do an XML-less JSF Navigation approach). For this I need to add a faces-config.xml. I did it, but after adding the faces-config I always get an error when I want to open my page.

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

If I remove the faces-config everything works great (But then I have no navigation :( ).

Here are my maven dependencies: 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

And here is my 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>

And here is my 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>

Does anyone of you know why the application is crashing?

Thx in advance!

TJ

TerenceJackson
  • 1,776
  • 15
  • 24
  • 1
    Please notice that the XML-less navigation article which you linked there is targeted on JSF 1.x (written at November 2008 while JSF 2.x is introduced at December 2009) and is later already taken over in standard JSF 2.0 API! Ignore that article, remove the custom navigation handler and just utilize the new JSF 2.0 builtin feature of [implicit navigation](http://balusc.blogspot.com/2011/09/communication-in-jsf-20.html#ImplicitNavigation). Again, be very careful that you don't focus too much on JSF 1.x targeted articles. Lot of things are done differently and more elegantly in JSF 2.x. – BalusC Apr 23 '12 at 18:27

1 Answers1

2

Your faces-config.xml header still pointing to 1.2 DTD. This may lead to unpredicatable error. I would suggest update it to 2.0 DTD and try.

<?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">
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
kosa
  • 65,990
  • 13
  • 130
  • 167