title: Tomcat with APR causing Thread Blocking
body: <p>I have my Tomcat environment using APR (<a href="http://ivf.dlr.de/docs/apr.html" rel="nofollow">Apache Portable Runtime</a>)Listener:</p>
  
  <pre><code>&lt;Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /&gt;
  </code></pre>
  
  <p>I am using below connector, which i assume is a blocking type:</p>
  
  <pre><code>&lt;Connector port="8080" protocol="HTTP/1.1" 
             maxThreads="150" connectionTimeout="20000"      redirectPort="8443" /&gt;
  </code></pre>
  
  <p>In one of my webapp i am running a dll as Java Process to validate some data. This dll is accessed as a Process whenever is required. I have separate Thread to terminate this Process if not used for few minutes. </p>
  
  <p>Now i am facing a weired issue where with Apache Tomcat 6.0.43 (both 64 and 32 bit), the http thread that has started this process gets stuck. From thread dump i get this stack trace:</p>
  
  <pre><code>"http-8080-2" - Thread t@55
     java.lang.Thread.State: RUNNABLE
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:152)
      at java.net.SocketInputStream.read(SocketInputStream.java:122)
      at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
      at java.io.BufferedInputStream.read(BufferedInputStream.java:254)
      - locked &lt;1559b4d1&gt; (a java.io.BufferedInputStream)
      at org.apache.commons.httpclient.HttpParser.readRawLine(HttpParser.java:77)
      at org.apache.commons.httpclient.HttpParser.readLine(HttpParser.java:105)
      at org.apache.commons.httpclient.HttpConnection.readLine(HttpConnection.java:1118)
  </code></pre>
  
  <p>To ascertain that the native process is not causing the issue, i ran few other external exe's with same result.</p>
  
  <p>During my research i found that if i comment the above listed AprListener property from the server.xml, things start working. 
  This behavior is very inconsistent across different versions of Tomcat, e.g. in Tomcat 6.0.10, i am not facing the issue. Then i upgraded to Tomcat 8, i faced this issue. I have tried with many versions of Tomcat and all reslt in same behavior. </p>
  
  <p>So, is this APR interfering with my own process calls? Or is there something that i am missing. Anyone who have seen any such tomcat bugs or fixes can point me as well.</p>