<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Red Leopard &#187; tomcat</title>
	<atom:link href="http://www.redleopard.com/tag/tomcat/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redleopard.com</link>
	<description>A Stranger in a Strange Land</description>
	<lastBuildDate>Mon, 07 Jun 2010 22:59:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>tomcat error: clearThreadLocalMap</title>
		<link>http://www.redleopard.com/2010/03/tomcat-error-clearthreadlocalmap/</link>
		<comments>http://www.redleopard.com/2010/03/tomcat-error-clearthreadlocalmap/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 00:43:57 +0000</pubDate>
		<dc:creator>kelly</dc:creator>
				<category><![CDATA[KellyBlog]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.redleopard.com/?p=877</guid>
		<description><![CDATA[I&#8217;m trying to move from Tomcat 5.5.28 to Tomcat 6.0.26 for my Struts2-based webapp. I previously tried&#8211;unsuccessfully&#8211;to make the move to Tomcat 6.0.20 but had to roll back. There were problems with the underlying connection to mail that I didn&#8217;t have time to track down.
I use a standard stack.


$ cat /etc/redhat-release
CentOS release 5.4 (Final)

$ /usr/sbin/httpd [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to move from Tomcat 5.5.28 to Tomcat 6.0.26 for my Struts2-based webapp. I previously tried&#8211;unsuccessfully&#8211;to make the move to Tomcat 6.0.20 but had to roll back. There were problems with the underlying connection to mail that I didn&#8217;t have time to track down.</p>
<p>I use a standard stack.</p>
<div class="terminal">
<pre>
$ <span style="color: green;">cat /etc/redhat-release</span>
CentOS release 5.4 (Final)

$ <span style="color: green;">/usr/sbin/httpd -v</span>
Server version: Apache/2.2.3
Server built:   Nov 12 2009 18:43:41

$ <span style="color: green;">java -version</span>
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)

$ <span style="color: green;">ls -l /usr/local | grep tomcat</span>
… tomcat -> ./src/apache-tomcat-6.0.26
</pre>
</div>
<p>Be forewarned: I&#8217;m jotting down my notes and this seems to be the easiest place for me to find them later. If you find something unclear or missing, leave a comment and I will look into it.</p>
<p>I habitually edit and format log data to cut down on the noise and improve readability. This torques the purists. I&#8217;m not a purist. I won&#8217;t change the essentials but I will eliminate—what I consider to be—unimportant details. For example, I will replace unimportant date stamps</p>
<div class="terminal">
<pre>
Mar 11, 2010 4:30:33 PM
</pre>
</div>
<p>with a marker that&#8217;s less distracting</p>
<div class="terminal">
<pre>
$TIME
</pre>
</div>
<p>I also will wrap output so it will fit nicely in my blog. When I wrap, I will use the marker &#8220;↩&#8221;.</p>
<p>As an example, the <code>$CATALINA_HOME/logs/catalina.out</code> log entry produced upon startup:</p>
<div class="terminal">
<pre>
$TIME org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.20.

$TIME org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true],↩
accept filters [false], random [true].

$TIME org.apache.coyote.ajp.AjpAprProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009

$TIME org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 544 ms

$TIME org.apache.catalina.core.StandardService start
INFO: Starting service Catalina

$TIME org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.26

$TIME org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml

$TIME org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml

$TIME org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ws

$TIME org.apache.coyote.ajp.AjpAprProtocol start
INFO: Starting Coyote AJP/1.3 on ajp-8009

$TIME org.apache.catalina.startup.Catalina start
INFO: Server startup in 2131 ms
</pre>
</div>
<p>So far, so good.</p>
<p>You can see from the startup entry that I am using the Tomcat Native Library. There is a nice section in <a href="http://my.safaribooksonline.com/9780596101060">Tomcat: The Definitive Guide</a> that explains why <b>not</b> to use the native library but I use it anyway.</p>
<p>You&#8217;ll also notice that I don&#8217;t listen on port 8080; Tomcat connects only to Apache httpd via mod_jk.</p>
<div class="terminal">
<pre>
# <span style="color: green;"> grep -E "8[0-9]{3}" /usr/local/tomcat/conf/server.xml</span>
&lt;Server port="8005" shutdown="SHUTDOWN"&gt;
port="8009" 

# <span style="color: green;">cat /etc/httpd/conf/workers.properties</span>
workers.tomcat_home=/usr/local/tomcat
workers.java_home=/usr/java/default
ps=/

worker.list=router

worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1

worker.worker1.redirect=worker2

worker.worker2.port=8009
worker.worker2.host=localhost
worker.worker2.type=ajp13
worker.worker2.lbfactor=1

worker.worker2.activation=disabled

worker.router.type=lb
worker.router.balance_workers=worker1,worker2
</pre>
</div>
<p>Everything else is pretty standard.</p>
<p>When I go to shut down, Tomcat 6.0.26 gives me a few surprise errors.</p>
<div class="terminal">
<pre>
$TIME org.apache.coyote.ajp.AjpAprProtocol pause
INFO: Pausing Coyote AJP/1.3 on ajp-8009

$TIME org.apache.catalina.core.StandardService stop
INFO: Stopping service Catalina

$TIME org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: A web application created a ThreadLocal↩
  with key of type [null]↩
  (value [com.opensymphony.xwork2.inject.ContainerImpl$10@5a9b8ff9])↩
  and a value of type [java.lang.Object[]]↩
  (value [[Ljava.lang.Object;@1b0952e8])↩
  but failed to remove it when the web application was stopped.↩
  To prevent a memory leak, the ThreadLocal has been forcibly removed.

$TIME org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: A web application created a ThreadLocal↩
  with key of type [null]↩
  (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1220b36])↩
  and a value of type [java.lang.Object[]]↩
  (value [[Ljava.lang.Object;@620e06ce])↩
  but failed to remove it when the web application was stopped.↩
  To prevent a memory leak, the ThreadLocal has been forcibly removed.

$TIME org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: A web application created a ThreadLocal↩
  with key of type [null]
  (value [com.opensymphony.xwork2.inject.ContainerImpl$10@1b1402c4])↩
  and a value of type [java.lang.Object[]]↩
  (value [[Ljava.lang.Object;@3ec19fbf])↩
  but failed to remove it when the web application was stopped.↩
  To prevent a memory leak, the ThreadLocal has been forcibly removed.

$TIME org.apache.coyote.ajp.AjpAprProtocol destroy
INFO: Stopping Coyote AJP/1.3 on ajp-8009
</pre>
</div>
<p>The question I have is, &#8220;Is this new or is the new listener included in the Tomcat 6 server.xml file reporting a previously missed problem?&#8221;</p>
<p>It turns out that Tomcat 6 has new listeners that detect this kind of problem.</p>
<p>&#8220;<a href="http://forum.springsource.org/showthread.php?t=84202">The new Tomcat 6 adds a series of listeners to prevent against memory leaks and one of them, is against ThreadLocals</a>.&#8221;</p>
<p>&#8220;<a href="http://old.nabble.com/Issue-while-stopping-Tomcat-6.0.24-using-java-1.6.0_18-td27821873.html">The new memory leak detection code in Tomcat has found an issue with an application that needs to be fixed</a>.&#8221;</p>
<p>This seems to be a case of an existing problem which is just now being reported.</p>
<p>I should mention that I started tomcat and immediately shut it down. My webapp did not process any http requests between startup and shutdown. That doesn&#8217;t preclude my webapp from being the culprit, though.</p>
<p>I would be happier if Tomcat and/or Struts2 (Spring?) in a future release could eliminate the SEVERE notice. There&#8217;s something unsettling about ignoring serious warnings.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redleopard.com/2010/03/tomcat-error-clearthreadlocalmap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Failed to create poller with specified size</title>
		<link>http://www.redleopard.com/2009/04/failed-to-create-poller-with-specified-size/</link>
		<comments>http://www.redleopard.com/2009/04/failed-to-create-poller-with-specified-size/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 23:35:04 +0000</pubDate>
		<dc:creator>kelly</dc:creator>
				<category><![CDATA[KellyBlog]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://www.redleopard.com/?p=602</guid>
		<description><![CDATA[It had always bugged me that I got this warning on my OS X, MacBook Pro development system. (Well, it&#8217;s really an INFO, not a WARN but it bugged me nonetheless.)


Apr 8, 2009 4:10:55 PM org.apache.coyote.ajp.AjpAprProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009

	&#60;!-- snip --&#62;

Apr 8, 2009 4:10:58 PM org.apache.tomcat.util.net.AprEndpoint allocatePoller
INFO: Failed to create poller with [...]]]></description>
			<content:encoded><![CDATA[<p>It had always bugged me that I got this warning on my OS X, MacBook Pro development system. (Well, it&#8217;s really an INFO, not a WARN but it bugged me nonetheless.)</p>
<div class="terminal">
<pre>
Apr 8, 2009 4:10:55 PM org.apache.coyote.ajp.AjpAprProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009

	&lt;!-- snip --&gt;

Apr 8, 2009 4:10:58 PM org.apache.tomcat.util.net.AprEndpoint allocatePoller
<b>INFO: Failed to create poller with specified size of 8192</b>

	&lt;!-- snip --&gt;

Apr 8, 2009 4:10:58 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2703 ms
</pre>
</div>
<p>I never saw this issue on my CentOS production servers so I figured it must be a BSD thing. It any rate, I recently tracked down a solution: add a pollerSize attribute to Tomcat&#8217;s connector element in server.xml.</p>
<div class="terminal">
<pre>
&lt;Connector
  pollerSize="1024"
  port="8009"
  URIEncoding="UTF-8"
  enableLookups="false"
  redirectPort="8443"
  maxPostSize="104857600"
  protocol="AJP/1.3" /&gt;
</pre>
</div>
<p>For a full listing of my server.xml, see <a href="http://www.redleopard.com/2009/04/utf8-jdbc-on-tomcat/">UTF8 JDBC on Tomcat</a>.</p>
<p>I suppose I could have mucked with OS X&#8217;s limits but somehow this solution seemed less problematic. I&#8217;m not serving to the web from my laptop so I feel comfortable lowering the pollerSize. Besides, I had two years of history in which a problem never arose even though tomcat failed to create the poller&#8230; I&#8217;ve had a couple of months now in which the poller has been created and works fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redleopard.com/2009/04/failed-to-create-poller-with-specified-size/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
