title: Weblogic IOException and Chunking
body: <p>I'm working in an environment that runs ATG (Oracle Commerce) 11.1 on Weblogic 12c and connects to an Endeca instance. In the Weblogic log files I get a frequent <code>IOException</code>, which I believe has a knock-on effect on the overall stability of the site. The error is as follow:</p>
  
  <pre><code>####&lt;24 Nov 2015 2:47:39 PM&gt; &lt;Error&gt; &lt;HTTP&gt; &lt;SERVER-1&gt; &lt;instance-1&gt; &lt;[ACTIVE] ExecuteThread: '116' for queue: 'weblogic.kernel.Default (self-tuning)'&gt; &lt;&lt;WLS Kernel&gt;&gt; &lt;&gt; &lt;&gt; &lt;1448369259872&gt; &lt;BEA-101019&gt; &lt;[ServletContext@1433232248[app:ATGProduction module:store path:null spec-version:3.0]] Servlet failed with an IOException.
  java.io.IOException: An existing connection was forcibly closed by the remote host
  at sun.nio.ch.SocketDispatcher.write0(Native Method)
  at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:51)
  at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
  at sun.nio.ch.IOUtil.write(IOUtil.java:65)
  at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487)
  at weblogic.socket.NIOSocketMuxer$NIOOutputStream.writeInternal(NIOSocketMuxer.java:1064)
  at weblogic.socket.NIOSocketMuxer$NIOOutputStream.write(NIOSocketMuxer.java:983)
  at weblogic.servlet.internal.ChunkOutput.writeChunkTransfer(ChunkOutput.java:622)
  at weblogic.servlet.internal.ChunkOutput.writeChunks(ChunkOutput.java:587)
  at weblogic.servlet.internal.ChunkOutput.flush(ChunkOutput.java:472)
  at weblogic.servlet.internal.CharsetChunkOutput.flush(CharsetChunkOutput.java:301)
  at weblogic.servlet.internal.ChunkOutput$3.checkForFlush(ChunkOutput.java:727)
  at weblogic.servlet.internal.CharsetChunkOutput.write(CharsetChunkOutput.java:203)
  at weblogic.servlet.internal.ChunkOutputWrapper.write(ChunkOutputWrapper.java:153)
  at weblogic.servlet.jsp.JspWriterImpl.write(JspWriterImpl.java:275)
  at jsp_servlet._tags._store.__contentitem_tag._jsp__tag2(__contentitem_tag.java:321)
  at jsp_servlet._tags._store.__contentitem_tag._jsp__tag1(__contentitem_tag.java:272)
  at jsp_servlet._tags._store.__contentitem_tag.doTag(__contentitem_tag.java:196)
  at jsp_servlet._cartridges._pageslot.__pageslot._jsp__tag6(__pageslot.java:412)
  at jsp_servlet._cartridges._pageslot.__pageslot._jsp__tag5(__pageslot.java:371)
  at jsp_servlet._cartridges._pageslot.__pageslot._jsp__tag2(__pageslot.java:258)
  at jsp_servlet._cartridges._pageslot.__pageslot._jspService(__pageslot.java:128)
  at weblogic.servlet.jsp.JspBase.service(JspBase.java:35)
  at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
  at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
  at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
  at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
  at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:243)
  at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:587)
  at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:273)
  </code></pre>
  
  <p>The error happens consistently in the <code>contentitem.tag</code> file, which is as follow:</p>
  
  <pre><code>&lt;%@ tag language="java" pageEncoding="UTF-8"%&gt;
  &lt;%@ include file="/include/taglibs.jspf" %&gt;
  
  &lt;%@ attribute name="contentItem" required="true" rtexprvalue="true" type="java.util.Map"%&gt;
  
  &lt;dsp:getvalueof var="include" value="${contentItem['@type']}" /&gt;
  &lt;c:choose&gt;
      &lt;c:when test="${empty contentItemKey &amp;&amp; !empty include}"&gt;
          &lt;dsp:include page="/cartridges/${include}/${include}.jsp"&gt;
              &lt;dsp:param name="contentItem" value="${contentItem}"/&gt;
          &lt;/dsp:include&gt;
      &lt;/c:when&gt;
      &lt;c:when test="${!empty contentItemKey}"&gt;
          &lt;c:out value="${contentItem[contentItemKey]}" escapeXml="false" /&gt;
      &lt;/c:when&gt;   
  &lt;/c:choose&gt;
  </code></pre>
  
  <p>Would changing the ChunkSize parameter in Weblogic be of any benefit? It is still at the default 4k at the moment.</p>
  
  <p>Is it a coincidence that the issue always appears in the <code>contentitem.tag</code> file which is how we unpack and render Endeca related content? The tag file gets called recursively by the cartridges it includes.</p>
  
  <p>Any advice on how to resolve this issue, appreciated.</p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>While not answering the question explicitly, we've made significant strides into reducing (not eliminating) the <code>IOException</code> once we realised that the <code>&lt;page-check-seconds&gt;</code> directive in the weblogic.xml was inadvertently set to 0 (ie. compile pages on every request). This resulted in multiple threads trying to compile the same page fragment. Stability has been greatly improved but the <code>IOException</code> has not been eradicated.</p>