Question

Ok, I've run across my first StackOverflowError since joining this site, I figured this is a must post :-). My environment is Seam 2.0.1.GA, JBoss 4.2.2.GA and I'm using JSF. I am in the process of converting from a facelets view to JSP to take advantage of some existing JSP tags used on our existing site. I changed the faces-config.xml and the web.xml configuration files and started to receive the following error when trying to render a jsp page. Anyone have any thoughts?

2008-09-17 09:45:17,537 DEBUG [org.jboss.seam.contexts.FacesLifecycle] Begin JSF request for /form_home.jsp 2008-09-17 09:45:17,587 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception java.lang.StackOverflowError at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:210) at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:222) at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:222) at org.apache.catalina.core.ApplicationHttpRequest.getAttribute(ApplicationHttpRequest.java:222) ...

My faces-config.xml file is now empty with no FaceletsViewHandler:

<?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">

</faces-config>

And my Web.xml file:

<?xml version="1.0"?>
<web-app version="2.5" 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_2_5.xsd">
 <!-- Ajax4jsf -->
 <context-param>
  <param-name>org.richfaces.SKIN</param-name>
  <param-value>blueSky</param-value>
 </context-param>
  <!-- Seam -->
 <listener>
  <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
 </listener>


 <filter>
  <filter-name>Seam Filter</filter-name>
  <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
 </filter>

 <filter-mapping>
  <filter-name>Seam Filter</filter-name>
  <url-pattern>*.jsp</url-pattern>
 </filter-mapping>

 <servlet>
    <servlet-name>Seam Resource Servlet</servlet-name>
     <servlet-class>org.jboss.seam.servlet.SeamResourceServlet
     </servlet-class>
 </servlet>
 <servlet-mapping>
   <servlet-name>Seam Resource Servlet</servlet-name>
   <url-pattern>/seam/resource/*</url-pattern>
 </servlet-mapping>
 <!-- Seam end --> 

 <!-- JSF -->
 <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.jsp</param-value>
 </context-param>

 <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>*.jsp</url-pattern> 
 </servlet-mapping>
Was it helpful?

Solution

I was able to figure out this problem. Apparently you can not configure web.xml to have the same param-value of .jsp for Javax.faces.DEFAULT_SUFFIX as the Faces Servlet url-pattern (*.jsp). If you change your url-pattern to .jspx or to /whateverdirnameyouwant/ the application starts up with no stack overflow errors. (note: the key is that DEFAULT_SUFFIX and Faces Servlet url-pattern cannot be the same regardless of what they are.) Hope this helps anyone else that experiences this specific problem.

OTHER TIPS

Stack overflows in java are almost always caused by infinite recursion / method calls. In your case given the stack trace, it appears 'getAttribute()' is being called repeatedly until crash. While I'm not intimately familiar with the particular environments you are using, I would suggest checking your .jsp code for any of this type of behaviour (for example two methods that call each other)

So, I had a similar error. For me, it was that I had a JSF project and I was messing around with the file extensions. To start with, I had all my web files with extension .jsp. This was working, but then I wanted them to be all .jsf, then after that I went all in on using .xhtml. In the process, my web.xml file changed to accomodate xhtml and jsf. Changing the web.xml file was fine. What got me the StackOverflowError was that I had index.xhtml with a ui.include tag pointing to header.jsf. So I had a xhtml file pointing to a jsf file. I had thought that web.xml would be able to handle this, but it did not, I got the StackOverflowError. So, to fix this, now all my JSF files have extension .xhtml, and nested ui:include tags point to .xhtml files.

On the flip side, though, the browser url can handle the index.jsp, index.jsf, index.xhtml just fine. So the web.xml (with servlet mappings for jsp, jsf and xhtml) handles the browser url just fine, but not for what my problem above highlighted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top