Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a known problem and has been reported by yours truly as <a href="http://java.net/jira/browse/JAVASERVERFACES-2215" rel="noreferrer">issue 2215</a>. This will occur when the response buffer has overflowed (due to large content) and the response is been committed before the session is been created. This is result of bit overzealous attempts of Mojarra to postpone "unnecessary" session creation as much as possible (which is at its own a Good Thing though).</p> <p>Until they get it fixed, there are several workarounds:</p> <ol> <li><p>Create a <code>Filter</code> which does <a href="http://download.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getSession%28%29" rel="noreferrer"><code>HttpServletRequest#getSession()</code></a> before <a href="http://download.oracle.com/javaee/6/api/javax/servlet/FilterChain.html#doFilter%28javax.servlet.ServletRequest,%20javax.servlet.ServletResponse%29" rel="noreferrer"><code>FilterChain#doFilter()</code></a>. Advantage: no need to change JSF configuration/code. Disadvantage: when you want to avoid unnecessary session creation yourself as well.</p></li> <li><p>Call <a href="http://download.oracle.com/javaee/6/api/javax/faces/context/ExternalContext.html#getSession%28boolean%29" rel="noreferrer"><code>ExternalContext#getSession()</code></a> with <code>true</code> in bean's (post)constructor or <code>preRenderView</code> listener. Advantage: actually, nothing. Disadvantage: too hacky.</p></li> <li><p>Add a context parameter with name of <code>com.sun.faces.writeStateAtFormEnd</code> and value of <code>false</code> to <code>web.xml</code>. Advantage: unnecessary session creation will be really avoided as opposed to #1 and #2. Disadvantage: response will now be fully buffered in memory until <code>&lt;/h:form&gt;</code> is reached. If your forms are not extremely large, the impact should however be minimal. It would however still fail if your <code>&lt;h:form&gt;</code> starts relatively late in the view. This may be combined with #4.</p></li> <li><p>Add a context parameter with name of <code>javax.faces.FACELETS_BUFFER_SIZE</code> and a value of the Facelets response buffer size in bytes (e.g. <code>65535</code> for 64KB) so that the entire HTML output or at least the <code>&lt;h:form&gt;</code> (see #3) fits in the response buffer. Advantage/disadvantage, see #3.</p></li> <li><p>Add a context parameter with name of <code>javax.faces.STATE_SAVING_METHOD</code> and value of <code>client</code> to <code>web.xml</code>. Advantage: session will not be created at all unless you have session scoped beans. It also immediately solves potential <code>ViewExpiredException</code> cases. Disadvantage: increased network bandwidth usage. If you're using partial state saving, then the impact should however be minimal.</p></li> </ol> <p>As to why the problem disappears when you remove <code>&lt;h:form&gt;</code>, this is because no session needs to be created in order to store the view state.</p> <hr> <p><strong>Update</strong>: this has as per the duplicate <a href="http://java.net/jira/browse/JAVASERVERFACES-2277" rel="noreferrer">issue 2277</a> been fixed since Mojarra 2.1.8. So, you can also just upgrade to at least that version.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload