<?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>Java堂 &#187; resin</title>
	<atom:link href="http://www.javatang.com/archives/tag/resin/feed" rel="self" type="application/rss+xml" />
	<link>http://www.javatang.com</link>
	<description>Java Tang</description>
	<lastBuildDate>Thu, 08 Dec 2011 08:29:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Resin中对日志输出的配置</title>
		<link>http://www.javatang.com/archives/2010/11/14/1752494.html</link>
		<comments>http://www.javatang.com/archives/2010/11/14/1752494.html#comments</comments>
		<pubDate>Sun, 14 Nov 2010 06:17:52 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[JavaPlateform]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false">http://www.javatang.com/?p=494</guid>
		<description><![CDATA[Resin中对日志的设置主要有如下参数：log、logger、access-log、stdout-log和stderr-log。前两个放在&#60;resin&#62;标签，也就是主标签下面，其中log主要用于配置JDK logging API，logger用于指定需要log的包及level，跟log4j中的用法相似，只不过resin中level有个特殊的选项就是off，用于关闭日志输出；而后面三个*-log放在&#60;host&#62;或&#60;host-default&#62;下面，access用于HTTP输出，stdout用于标准输出(System.out)，stderr用于错误输出(System.err，对应log4j中的log.error)。 三个*-log中间的属性是相同的，所以我们集中来说明一下： path: 用于设定日志文件的路径，非常有意思的是它支持所谓的El Variables and Functions，也就是resin中的变量，比如${host.name}就是虚拟站点的id名称，所以如果将它放在&#60;host-default&#62;下面的话，将path设置为 logs/${host.name}/access.log的话可以将不同站点的日志存放在不同的目录下面。 archive-format: 这个参数可以设置日志归档的格式，如设置为access-%Y%m%d.log可以在归档的时候自动按日期进行归档命名。另外还有一个特性需要说明的是，resin竟然支持自动压缩log文件，而且设置的方法非常简单，只要后缀名是gz就可以了，如access-%Y%m%d.log.gz，这样归档的时候会自动压缩，而且支持windows和linux系统。 format: 用于设置每条日志输出的格式，这个非常简单，而且通常使用系统内置的格式就可以了。 rollover-size: 用来设置归档日志文件的最小尺寸，单位可以设置成kb、mb等等，默认为1mb。 rollover-period: 用来设置归档日志文件的周期，单位可以是1D（一天）、1W(一周)、1M（一个月）等。 最后给出一个范例供大家参考： &#60;!-- &#160;&#160; - Resin 3.1 configuration file. &#160; --&#62; &#60;resin&#160;xmlns=&#34;http://caucho.com/ns/resin&#34; &#160; &#160; &#160;&#160; xmlns:resin=&#34;http://caucho.com/ns/resin/core&#34;&#62; &#160; &#60;!-- &#160; &#160;&#160; - Logging configuration for the JDK logging API. &#160; &#160; --&#62; &#160; &#60;log&#160;name=&#34;&#34; level=&#34;off&#34; path=&#34;stdout:&#34; &#160; &#160; &#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Resin中对日志的设置主要有如下参数：log、logger、access-log、stdout-log和stderr-log。前两个放在&lt;resin&gt;标签，也就是主标签下面，其中log主要用于配置JDK logging API，logger用于指定需要log的包及level，跟log4j中的用法相似，只不过resin中level有个特殊的选项就是off，用于关闭日志输出；而后面三个*-log放在&lt;host&gt;或&lt;host-default&gt;下面，access用于HTTP输出，stdout用于标准输出(System.out)，stderr用于错误输出(System.err，对应log4j中的log.error)。</p>
<p>三个*-log中间的属性是相同的，所以我们集中来说明一下：</p>
<blockquote>
<li><b>path:</b> 用于设定日志文件的路径，非常有意思的是它支持所谓的<a href="http://caucho.com/resin-3.1/doc/el-var.xtp" target="_blank">El Variables and Functions</a>，也就是resin中的变量，比如${host.name}就是虚拟站点的id名称，所以如果将它放在&lt;host-default&gt;下面的话，将path设置为 logs/${host.name}/access.log的话可以将不同站点的日志存放在不同的目录下面。</li>
<li><b>archive-format:</b> 这个参数可以设置日志归档的格式，如设置为access-%Y%m%d.log可以在归档的时候自动按日期进行归档命名。另外还有一个特性需要说明的是，resin竟然支持自动压缩log文件，而且设置的方法非常简单，只要后缀名是gz就可以了，如access-%Y%m%d.log.gz，这样归档的时候会自动压缩，而且支持windows和linux系统。</li>
<li><b>format:</b> 用于设置每条日志输出的格式，这个非常简单，而且通常使用系统内置的格式就可以了。</li>
<li><b>rollover-size:</b> 用来设置归档日志文件的最小尺寸，单位可以设置成kb、mb等等，默认为1mb。</li>
<li><b>rollover-period:</b> 用来设置归档日志文件的周期，单位可以是1D（一天）、1W(一周)、1M（一个月）等。</li>
</blockquote>
<p>最后给出一个范例供大家参考：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">&lt;!--</span></li>
<li><span style="color: #ffa500;">&nbsp;&nbsp; - Resin 3.1 configuration file.</span></li>
<li><span style="color: #ffa500;">&nbsp; --&gt;</span></li>
<li><span style="color: Olive;">&lt;</span><span style="color: Green;">resin</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">xmlns</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">xmlns:resin</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin/core</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: #ffa500;">&lt;!--</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp;&nbsp; - Logging configuration for the JDK logging API.</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; --&gt;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">log</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">level</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">off</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">path</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">stdout:</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">timestamp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">[%H:%M:%S.%s] {%{thread}} </span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: #ffa500;">&lt;!--</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp;&nbsp; - 'info' for production</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp;&nbsp; - 'fine' or 'finer' for development and troubleshooting</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; --&gt;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">logger</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">com.caucho</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">level</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">info</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">logger</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">com.caucho.java</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">level</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">config</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">logger</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">com.caucho.loader</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">level</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">config</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">host-default</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">&lt;!--</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; - With another web server, like Apache, this can be commented out</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; - because the web server will log this information.</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; &nbsp; &nbsp; --&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">access-log</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">path</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">logs/${host.name}/access.log</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">archive-format</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">access-%Y%m%d.log.gz</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">format</span><span style="color: Gray;">='%</span><span style="color: #00008b;">h</span><span style="color: Gray;"> %</span><span style="color: #00008b;">l</span><span style="color: Gray;"> %</span><span style="color: #00008b;">u</span><span style="color: Gray;"> %</span><span style="color: #00008b;">t</span><span style="color: Gray;">&nbsp;</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">%r</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> %</span><span style="color: #00008b;">s</span><span style="color: Gray;"> %</span><span style="color: #00008b;">b</span><span style="color: Gray;"> </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">%{Referer}i</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">%{User-Agent}i</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">'</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">rollover-size</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">10mb</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">rollover-period</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">1D</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">&lt;!--</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; - stdout log and stderr log</span></li>
<li><span style="color: #ffa500;">&nbsp; &nbsp; &nbsp; &nbsp; --&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">stdout-log</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">path</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">logs/${host.name}/stdout.log</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">archive-format</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">stdout-%Y%m%d.log.gz</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">timestamp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">[%Y.%m.%d %H:%M:%S.%s]</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">rollover-size</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">10mb</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">rollover-period</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">1D</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">stderr-log</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">path</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">logs/${host.name}/stderr.log</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">archive-format</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">stderr-%Y%m%d.log.gz</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">timestamp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">[%Y.%m.%d %H:%M:%S.%s]</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">rollover-size</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">10mb</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">rollover-period</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">1D</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">host-default</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">resin</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>最后还有一个事情需要说明一下，如果在windows系统下<a href="http://www.javatang.com/archives/2007/06/20/1513177.html">将resin注册成服务程序</a>之后就会在log目录下产生jvm-defautl.log文件，而且这个文件会一直累加，所以会变的文件非常大而影响resin的性能。原来在<a href="http://www.javatang.com/archives/2007/06/20/1513177.html">Apache和Resin产生大容量日志的解决办法</a>这篇文件中提到的使用httpd -jvm-log NUL的方法在3.1中无法使用，而且查找了大量的文档也没有找到合适的方法，后来索性将log目录中的写入权限去掉了，重启resin也没有任何影响，算是解决了这个问题。</p>
<p>参考资料：</p>
<p>http://caucho.com/resin-3.1/doc/config-log.xtp</p>
<p>http://caucho.com/resin-3.1/doc/el-var.xtp#host</p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2008/03/18/2532264.html" rel="bookmark" class="crp_title">Apache+Resin泛域名的设置</a></li><li><a href="http://www.javatang.com/archives/2007/06/20/1513177.html" rel="bookmark" class="crp_title">Apache和Resin产生大容量日志的解决办法</a></li><li><a href="http://www.javatang.com/archives/2010/08/27/3629451.html" rel="bookmark" class="crp_title">Apache和Resin组合时UrlRewriteFilter失效的解决方法</a></li><li><a href="http://www.javatang.com/archives/2010/11/13/1228487.html" rel="bookmark" class="crp_title">Apache和Resin组合时间歇性出现503错误的解决方法</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2010/11/14/1752494.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache和Resin组合时间歇性出现503错误的解决方法</title>
		<link>http://www.javatang.com/archives/2010/11/13/1228487.html</link>
		<comments>http://www.javatang.com/archives/2010/11/13/1228487.html#comments</comments>
		<pubDate>Sat, 13 Nov 2010 09:12:28 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[JavaPlateform]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false">http://www.javatang.com/?p=487</guid>
		<description><![CDATA[使用Apache和Resin进行组合时，如果Resin关闭或中断的时会出现如下的HTTP 503错误： Service Temporarily Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. 造成这个错误的原因是因为Resin无法启动，可以单独访问resin（如8080端口）查看具体的错误。 我这里要说的是，在Resin和Apache都非常非常正常的情况下，间歇性的出现上述错误，也就是说不是一直有，而是偶尔出现这个错误，刷新下页面就好了。这个问题非常郁闷，后来在resin的bug报告中（见参考资料）竟然发现了解决的办法： The important configuration are load-balance-socket-timeout, socket-timeout, load-balance-idle-time and keepalive-timeout. The two load-balance-* configure mod_caucho. socket-timeout and keepalive-timeout configure the Resin side. load-balance-socket-timeout needs to be large enough to [...]]]></description>
			<content:encoded><![CDATA[<p>使用Apache和Resin进行组合时，如果Resin关闭或中断的时会出现如下的HTTP 503错误：</p>
<blockquote><p>
Service Temporarily Unavailable<br />
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
</p></blockquote>
<p>造成这个错误的原因是因为Resin无法启动，可以单独访问resin（如8080端口）查看具体的错误。</p>
<p>我这里要说的是，在Resin和Apache都非常非常正常的情况下，<strong>间歇性</strong>的出现上述错误，也就是说不是一直有，而是偶尔出现这个错误，刷新下页面就好了。这个问题非常郁闷，后来在resin的bug报告中（见参考资料）竟然发现了解决的办法：</p>
<blockquote><p>
The important configuration are load-balance-socket-timeout, socket-timeout, load-balance-idle-time and keepalive-timeout. The two load-balance-* configure mod_caucho. socket-timeout and keepalive-timeout configure the Resin side.</p>
<p>load-balance-socket-timeout needs to be large enough to handle any server-side processing delays before the first data.</p>
<p>socket-timeout and keepalive-timeout need to be larger than load-balance-idle-time because they need to keep the connection open for a keepalive request. </p>
<p>For a diagram, see</p>
<p>http://caucho.com/resin/admin/load-balancing.xtp</p>
</blockquote>
<p>也就是说，Resin在同Apache进行组合通讯的时候主要依靠四个参数：load-balance-socket-timeout, socket-timeout, load-balance-idle-time 和 keepalive-timeout，其中两个load-balance-*参数用来设置mod_caucho（就是与Apache组合的so文件），socket-timeout和keepalive-timeout用来设置Resin。至于参数数值的大小顺序依此是：load-balance-socket-timeout &gt; socket-timeout 和 keepalive-timeout &gt; load-balance-idle-time。上述四个参数的官方说明地址为：<a href="http://caucho.com/resin-3.1/doc/server-tags.xtp" target="_blank">http://caucho.com/resin-3.1/doc/server-tags.xtp</a></p>
<p>那为什么会间歇性出现503错误呢？这个是因为resin默认的socket-timeout为65s，时间太短了，有些比较大的请求在这个时间之内还没有进行完。综合上面所说，参考的配置如下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">resin</span><span style="color: Gray;"> ...</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">cluster</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">app-tier</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">server-default</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">socket-timeout</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">180s</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">socket-timeout</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">keepalive-max</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">3000</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">keepalive-max</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">keepalive-timeout</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">180s</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">keepalive-timeout</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">load-balance-idle-time</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">120s</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">load-balance-idle-time</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">server-default</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">cluster</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">resin</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>从此，这个世界清净了。</p>
<p>参考资料：<br />
<a href="http://bugs.caucho.com/view.php?id=2715" target="_blank">Apache 2.2.x + Resin 3.1.x: frequent 503 status error messages (Service Temporarily Unavailable)</a><br />
<a href="http://bugs.caucho.com/view.php?id=2862" target="_blank">0002862: Apache + Resin and 503 HTTP Error</a><br />
<a href="http://aiter.javaeye.com/blog/391456" target="_blank">resin apache问题</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2011/10/18/1847563.html" rel="bookmark" class="crp_title">Ext中设置Ajax超时时间</a></li><li><a href="http://www.javatang.com/archives/2007/07/04/1548182.html" rel="bookmark" class="crp_title">PHP中出现“Unable to load dynamic library”问题的解决方法</a></li><li><a href="http://www.javatang.com/archives/2010/11/14/1752494.html" rel="bookmark" class="crp_title">Resin中对日志输出的配置</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li><li><a href="http://www.javatang.com/archives/2007/11/02/0146237.html" rel="bookmark" class="crp_title">“终端服务超出最大允许连接数”问题产生原因及解决方法</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2010/11/13/1228487.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache和Resin组合时UrlRewriteFilter失效的解决方法</title>
		<link>http://www.javatang.com/archives/2010/08/27/3629451.html</link>
		<comments>http://www.javatang.com/archives/2010/08/27/3629451.html#comments</comments>
		<pubDate>Fri, 27 Aug 2010 09:36:29 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false">http://www.javatang.com/?p=451</guid>
		<description><![CDATA[目前在Spring3.0的官方example中都使用UrlRewriteFilter来做伪静态，单独运行在Resin等JavaEE Web容器中的时候一切都OK，但是一旦与Apache一起组合的时候总是会出现404或403错误，当然UrlRewriteFilter所设定的规则也无效。 造成这种现象的原因是因为在默认情况下，静态的资源均由Apache进行处理，而jsp或者由web.xml所映射的servlet均交给resin进行处理。如果web项目没有使用UrlRewriteFilter则一切OK，但是使用了UrlRewriteFilter之后，由servlet所映射的地址并不是/*即所有资源了，而是类似/app/*这样的设置。也就是说，用户所请求的资源首先由Apache判断一下，然后再由选择的交给Resin，最后才执行UrlRewriteFilter的规则。 知道了原因，解决的方法也就出来了，只要告诉Apache将所有的资源都交由Resin来处理就可以了，可以使用Resin的servlet-mapping方法进行配置，配置如下： &#60;servlet-mapping url-pattern='/*' servlet-name='plugin_match'/&#62; 其中plugin_match是Resin内置的servlet，按照resin官方的解释就是Resin告诉Apache将所有的符合url-pattern规则要求的请求都发送给它进行处理。 因为servlet-mapping是resin特有的，所以建议将此也放在resin-web.xml中，然后放在项目中的WEB-INF目录下： &#60;web-app xmlns=&#34;http://caucho.com/ns/resin&#34; &#160; &#160; &#160; &#160;&#160; xmlns:resin=&#34;http://caucho.com/ns/resin/core&#34;&#62; &#160; &#160; &#60;servlet-mapping&#160;url-pattern='/*' servlet-name='plugin_match'/&#62; &#60;/web-app&#62; 参考资料： Apache的UrlRewrite和Resin的配置问题 Resin官方对servlet-mapping的说明 Related Posts:Resin 3.0.x 经验总结DWR文档之开始使用 DWR如何使用DWR2.0的注解功能Apache+Resin下如何写伪静态和301跳转Resin中对日志输出的配置]]></description>
			<content:encoded><![CDATA[<p>目前在Spring3.0的官方example中都使用UrlRewriteFilter来做伪静态，单独运行在Resin等JavaEE Web容器中的时候一切都OK，但是一旦与Apache一起组合的时候总是会出现404或403错误，当然UrlRewriteFilter所设定的规则也无效。</p>
<p>造成这种现象的原因是因为在默认情况下，静态的资源均由Apache进行处理，而jsp或者由web.xml所映射的servlet均交给resin进行处理。如果web项目没有使用UrlRewriteFilter则一切OK，但是使用了UrlRewriteFilter之后，由servlet所映射的地址并不是/*即所有资源了，而是类似/app/*这样的设置。也就是说，用户所请求的资源首先由Apache判断一下，然后再由选择的交给Resin，最后才执行UrlRewriteFilter的规则。</p>
<p>知道了原因，解决的方法也就出来了，只要告诉Apache将所有的资源都交由Resin来处理就可以了，可以使用Resin的servlet-mapping方法进行配置，配置如下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">servlet-mapping</span><span style="color: Gray;"> </span><span style="color: #00008b;">url-pattern</span><span style="color: Gray;">='/*' </span><span style="color: #00008b;">servlet-name</span><span style="color: Gray;">='</span><span style="color: #00008b;">plugin_match</span><span style="color: Gray;">'</span><span style="color: Olive;">/&gt;</span></li></ol></div>
<p>其中plugin_match是Resin内置的servlet，按照resin官方的解释就是Resin告诉Apache将所有的符合url-pattern规则要求的请求都发送给它进行处理。</p>
<p>因为servlet-mapping是resin特有的，所以建议将此也放在resin-web.xml中，然后放在项目中的WEB-INF目录下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">web-app</span><span style="color: Gray;"> </span><span style="color: #00008b;">xmlns</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">xmlns:resin</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin/core</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">servlet-mapping</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">url-pattern</span><span style="color: Gray;">='/*' </span><span style="color: #00008b;">servlet-name</span><span style="color: Gray;">='</span><span style="color: #00008b;">plugin_match</span><span style="color: Gray;">'</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">web-app</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>参考资料：<br />
<a href="http://highbird.blog.sohu.com/70318160.html" target="_blank">Apache的UrlRewrite和Resin的配置问题</a><br />
<a href="http://www.caucho.com/resin-3.0/config/webapp.xtp#servlet-mapping" target="_blank">Resin官方对servlet-mapping的说明</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li><li><a href="http://www.javatang.com/archives/2006/10/20/254879.html" rel="bookmark" class="crp_title">DWR文档之开始使用 DWR</a></li><li><a href="http://www.javatang.com/archives/2008/07/07/5648271.html" rel="bookmark" class="crp_title">如何使用DWR2.0的注解功能</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li><li><a href="http://www.javatang.com/archives/2010/11/14/1752494.html" rel="bookmark" class="crp_title">Resin中对日志输出的配置</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2010/08/27/3629451.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在Eclipse WTP中加入Resin server adapter</title>
		<link>http://www.javatang.com/archives/2009/12/30/0134324.html</link>
		<comments>http://www.javatang.com/archives/2009/12/30/0134324.html#comments</comments>
		<pubDate>Wed, 30 Dec 2009 06:01:34 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[JavaPlateform]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[eclipse插件]]></category>
		<category><![CDATA[resin]]></category>
		<category><![CDATA[wtp]]></category>

		<guid isPermaLink="false">http://www.javatang.com/?p=324</guid>
		<description><![CDATA[目前Eclipse的WTP用来开发JavaEE的功能越来越强大了，再配合上Maven和Ant，完全可以将MyEclipse丢到垃圾桶了。但是在使用WTP进行Server配置的时候发现竟然不支持Resin，后来Google了一下，找到两个解决的方法： 1. Amateras 这个是一个日本人写的Eclipse插件，可以绑定Resin到WTP中，不过他支持的Eclipse和Resin的版本都比较低，而且好久都没有更新了，不推荐使用。 2. The Resin Eclipse plugin 这个是在Resin的官方WIKI上发现的一个Eclipse插件，比较稳定也比较活跃，是Resin官方推荐使用的插件，Eclipse Update地址是：http://caucho.com/eclipse，安装之后就会在Server Adapter里面出现Resin Server了。 参考资料： IDE-CauchoWiki WTP扩展(1)：增加Resin Server Runtime Environments Related Posts:Ubuntu下面安装Macbuntu及安装之后需要修改的几个问题m2eclipse插件使用中提示jar包找不到的解决方法查找接口实现类的Eclipse插件Resin中对日志输出的配置Apache和Resin组合时间歇性出现503错误的解决方法]]></description>
			<content:encoded><![CDATA[<p>目前Eclipse的WTP用来开发JavaEE的功能越来越强大了，再配合上Maven和Ant，完全可以将MyEclipse丢到垃圾桶了。但是在使用WTP进行Server配置的时候发现竟然不支持Resin，后来Google了一下，找到两个解决的方法：<br />
1. <a href="https://sourceforge.jp/projects/amateras/" target="_blank">Amateras</a> 这个是一个日本人写的Eclipse插件，可以绑定Resin到WTP中，不过他支持的Eclipse和Resin的版本都比较低，而且好久都没有更新了，不推荐使用。</p>
<p>2. <a href="http://wiki.caucho.com/IDE" target="_blank">The Resin Eclipse plugin</a>  这个是在Resin的<a href="http://wiki.caucho.com/IDE" target="_blank">官方WIKI</a>上发现的一个Eclipse插件，比较稳定也比较活跃，是Resin官方推荐使用的插件，Eclipse Update地址是：http://caucho.com/eclipse，安装之后就会在Server Adapter里面出现Resin Server了。<br />
<a href="http://www.javatang.com/wp-content/WTP_Resin.png"><img src="http://www.javatang.com/wp-content/WTP_Resin-251x300.png" alt="" title="WTP_Resin" width="251" height="300" class="alignnone size-medium wp-image-325" /></a></p>
<p>参考资料：<br />
<a href="http://wiki.caucho.com/IDE" target="_blank">IDE-CauchoWiki</a><br />
<a href="http://blog.csdn.net/pizzame/archive/2009/01/06/3720029.aspx" target="_blank">WTP扩展(1)：增加Resin Server Runtime Environments </a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2010/11/27/1657519.html" rel="bookmark" class="crp_title">Ubuntu下面安装Macbuntu及安装之后需要修改的几个问题</a></li><li><a href="http://www.javatang.com/archives/2010/01/31/3312389.html" rel="bookmark" class="crp_title">m2eclipse插件使用中提示jar包找不到的解决方法</a></li><li><a href="http://www.javatang.com/archives/2007/07/04/4045184.html" rel="bookmark" class="crp_title">查找接口实现类的Eclipse插件</a></li><li><a href="http://www.javatang.com/archives/2010/11/14/1752494.html" rel="bookmark" class="crp_title">Resin中对日志输出的配置</a></li><li><a href="http://www.javatang.com/archives/2010/11/13/1228487.html" rel="bookmark" class="crp_title">Apache和Resin组合时间歇性出现503错误的解决方法</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2009/12/30/0134324.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache+Resin下如何写伪静态和301跳转</title>
		<link>http://www.javatang.com/archives/2008/10/18/1942276.html</link>
		<comments>http://www.javatang.com/archives/2008/10/18/1942276.html#comments</comments>
		<pubDate>Sat, 18 Oct 2008 19:19:42 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[SearchEngine]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[resin]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://www.javatang.com/archives/2008/10/18/1942276.html</guid>
		<description><![CDATA[目前网上大多数资料都是介绍如何在Apache中设置伪静态的，在Resin中很少提及，经过实践实现了这一点，现在做如下总结。 1. Apache下如何写伪静态和301重定向 直接上代码（以本站域名为例）： &#60;IfModule mod_rewrite.c&#62; &#160;&#160; &#160;RewriteEngine On &#160;&#160; &#160;# 叹号表示非，L表示最终结果，不再循环；NC是不区分大小写。 &#160;&#160; &#160;RewriteCond %{http_host} !^www.javatang.com [NC] &#160;&#160; &#160;RewriteRule ^/(.*)$ http://www.javatang.com/$1 [R=301,NC,L] &#160;&#160; &#160;RewriteRule ^(.*)/index(.*)$ $1/index.html [R=301,NC] &#160; &#60;/IfModule&#62; 2. Resin下如何写伪静态和301重定向 Resin下的重定向也是由伪静态来写的，不过具体一些的话他同页面伪静态是分别由两个tag来完成的，页面伪静态由forward完成，301永久重定向由moved-permanently完成。 下面是具体的代码： &#60;rewrite-dispatch&#62; &#160; &#160; &#160; &#160; &#60;forward&#160;regexp=&#34;^(.*)/archives/([^/]+)/([^/]+).html$&#34; target=&#34;$1/archives.jsp?q=$3&#38;amp;a=$2&#34; /&#62; &#160; &#160; &#160; &#160; &#60;!-- HTTP 301 moved --&#62; &#160; &#160; &#160; &#160; &#60;moved-permanently&#160;regexp=&#34;^(.*)/index(.*)$&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>目前网上大多数资料都是介绍如何在Apache中设置伪静态的，在Resin中很少提及，经过实践实现了这一点，现在做如下总结。</p>
<p><strong>1. Apache下如何写伪静态和301重定向</strong><br />
直接上代码（以本站域名为例）：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;IfModule mod_rewrite.c&gt;</li>
<li>&nbsp;&nbsp; &nbsp;RewriteEngine On</li>
<li>&nbsp;&nbsp; &nbsp;# 叹号表示非，L表示最终结果，不再循环；NC是不区分大小写。</li>
<li>&nbsp;&nbsp; &nbsp;RewriteCond %{http_host} !^www.javatang.com [NC]</li>
<li>&nbsp;&nbsp; &nbsp;RewriteRule ^/(.*)$ http://www.javatang.com/$1 [R=301,NC,L]</li>
<li>&nbsp;&nbsp; &nbsp;RewriteRule ^(.*)/index(.*)$ $1/index.html [R=301,NC]</li>
<li>&nbsp; &lt;/IfModule&gt;</li></ol></div>
<p><strong>2. Resin下如何写伪静态和301重定向</strong><br />
Resin下的重定向也是由伪静态来写的，不过具体一些的话他同页面伪静态是分别由两个tag来完成的，页面伪静态由forward完成，301永久重定向由moved-permanently完成。</p>
<p>下面是具体的代码：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">rewrite-dispatch</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">forward</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">regexp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">^(.*)/archives/([^/]+)/([^/]+).html$</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">target</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">$1/archives.jsp?q=$3</span><span style="color: Navy;">&amp;amp;</span><span style="color: Red;">a=$2</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">&lt;!-- HTTP 301 moved --&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">moved-permanently</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">regexp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">^(.*)/index(.*)$</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">target</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">$1/index.html</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">rewrite-dispatch</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>这里需要特别注意的一点就是地址中的QueryString中&#038;连接符需要使用&amp;来代替，否则为出现错误。</p>
<p>因为JavaEE默认的web.xml文件不支持上述属性，所以可以在你的站点WEB-INF目录下创建一个resin-web.xml文件，这个文件会被Resin看作为站点配置文件，然后在文件中写下如下内容：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">web-app</span><span style="color: Gray;"> </span><span style="color: #00008b;">xmlns</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </span><span style="color: #00008b;">xmlns:resin</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://caucho.com/ns/resin/core</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">rewrite-dispatch</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">forward</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">regexp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">^(.*)/archives/([^/]+)/([^/]+).html$</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">target</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">$1/archives.jsp?q=$3</span><span style="color: Navy;">&amp;amp;</span><span style="color: Red;">a=$2</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">&lt;!-- HTTP 301 moved --&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">moved-permanently</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">regexp</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">^(.*)/index(.*)$</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">target</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">$1/index.html</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">rewrite-dispatch</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Olive;">&lt;/</span><span style="color: Green;">web-app</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p><strong>3. Apache+Resin组合的时候设置伪静态需要注意的地方</strong></p>
<p>二者组合中Resin主要完成Servlet所映射的地址为文件类型，而Apache完成其余部分，因此关于页面伪静态部分需要在Resin和Apache中同时设置才有效，否则有时候会出现404错误。但对于301永久重定向来说，如果是涉及域名部分的只需要在Apache中设置即可，如果二者都设置的时候会出现域名解析错误；如果涉及到页面部分的话需要在二者中都设置。</p>
<p>关于Resin如何同Apache组合请看这篇文章 <a href="http://www.javatang.com/archives/2006/08/21/010658.html" target="_blank">Resin 3.0.x 经验总结</a></p>
<p>关于Resin+Apache下如何设置泛域名请看这篇文章 <a href="http://www.javatang.com/archives/2008/03/18/2532264.html" target="_blank">Apache+Resin泛域名的设置</a></p>
<p>参考资料：<br />
<a href="http://www.caucho.com/resin/doc/rewrite-tags.xtp#moved-permanently" target="_blank">Resin url rewrite tags</a><br />
<a href="http://www.fosoo.cn/linux/16" target="_blank">Apache网站301永久重定向设置</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2007/06/20/1513177.html" rel="bookmark" class="crp_title">Apache和Resin产生大容量日志的解决办法</a></li><li><a href="http://www.javatang.com/archives/2008/03/18/2532264.html" rel="bookmark" class="crp_title">Apache+Resin泛域名的设置</a></li><li><a href="http://www.javatang.com/archives/2011/09/20/2831546.html" rel="bookmark" class="crp_title">Apache+Resin发布程序时一直出现403错误的解决办法</a></li><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li><li><a href="http://www.javatang.com/archives/2010/08/27/3629451.html" rel="bookmark" class="crp_title">Apache和Resin组合时UrlRewriteFilter失效的解决方法</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2008/10/18/1942276.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache+Resin泛域名的设置</title>
		<link>http://www.javatang.com/archives/2008/03/18/2532264.html</link>
		<comments>http://www.javatang.com/archives/2008/03/18/2532264.html#comments</comments>
		<pubDate>Tue, 18 Mar 2008 15:25:32 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false">http://www.javatang.com/archives/2008/03/18/2532264.html</guid>
		<description><![CDATA[在Apache中如果设置范域名的话使用 ServerAlias ，比如 &#60;VirtualHost *:80&#62; &#160; ServerName javatang.com &#160; ServerAlias *.javatang.com &#160; ... &#60;/VirtualHost&#62; 如果使用Apache+Resin架构的话，需要在Resin中设置同样的泛域名与Apache进行对应。在Resin中设置泛域名使用 host-alias-regexp 标签，对应于上面Apache在Resin中设置如下： &#60;host id=&#34;javatang.com&#34; root-directory=&#34;.&#34;&#62; &#160;&#160; &#60;host-alias-regexp&#62;^([^/]*).javatang.com&#60;/host-alias-regexp&#62; &#160;&#160; ... &#60;/host&#62; 参考资料： host-alias-regexp apache、resin泛域名、多域名设置 Related Posts:Resin中对日志输出的配置Apache+Resin下如何写伪静态和301跳转Apache整合Tomcat之后的优化Resin 3.0.x 经验总结实现WordPress的Permalinks]]></description>
			<content:encoded><![CDATA[<p>在Apache中如果设置范域名的话使用 ServerAlias ，比如</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;VirtualHost *:80&gt;</li>
<li>&nbsp; ServerName javatang.com</li>
<li>&nbsp; ServerAlias *.javatang.com</li>
<li>&nbsp; ...</li>
<li>&lt;/VirtualHost&gt;</li></ol></div>
<p>如果使用Apache+Resin架构的话，需要在Resin中设置同样的泛域名与Apache进行对应。在Resin中设置泛域名使用 host-alias-regexp 标签，对应于上面Apache在Resin中设置如下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;host id=&quot;javatang.com&quot; root-directory=&quot;.&quot;&gt;</li>
<li>&nbsp;&nbsp; &lt;host-alias-regexp&gt;^([^/]*).javatang.com&lt;/host-alias-regexp&gt;</li>
<li>&nbsp;&nbsp; ...</li>
<li>&lt;/host&gt;</li></ol></div>
<p>参考资料：<br />
<a href="http://caucho.com/resin/doc/host-tags.xtp#host-alias-regexp" target="_blank">host-alias-regexp </a><br />
<a href="http://hi.baidu.com/mygia/blog/item/5c1bcafdaba44547d7887d1b.html" target="_blank">apache、resin泛域名、多域名设置</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2010/11/14/1752494.html" rel="bookmark" class="crp_title">Resin中对日志输出的配置</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li><li><a href="http://www.javatang.com/archives/2006/04/24/400519.html" rel="bookmark" class="crp_title">Apache整合Tomcat之后的优化</a></li><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li><li><a href="http://www.javatang.com/archives/2006/03/14/14246.html" rel="bookmark" class="crp_title">实现WordPress的Permalinks</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2008/03/18/2532264.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache和Resin产生大容量日志的解决办法</title>
		<link>http://www.javatang.com/archives/2007/06/20/1513177.html</link>
		<comments>http://www.javatang.com/archives/2007/06/20/1513177.html#comments</comments>
		<pubDate>Wed, 20 Jun 2007 00:15:13 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[JavaPlateform]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[昨天服务器上网站无故无法访问，重启Apache之后过一段时间又无法访问。后来无意间看到Apache的日志文件(access.log)竟然有7G多，赶紧删除之再重启Apache就OK了。但是总是这样也不是办法，如果时间一长忘记清空日志文件的话又会造成Apache死掉，另外之前Resin也产生过这样的问题。后来综合Google后的信息采用了如下的解决方法： 1. Apache日志 减少日志大小有两种方法，一种是修改日志记录级别，可以将默认的warn级别提升为error级别； LogLevel error 另外一种方法就是将日志文件按照每天创建一个文件的方式产生，这样就不会将所有的信息写入到一个文件。在Linux下可以将 httpd.conf 中 CustomLog logs/access.log common 修改为： CustomLog &#34;&#124;/usr/local/apache/bin/rotatelogs /usr/local/apache/logs/%Y_%m_%d.access.log 86400 480&#34; common Windows下没有rotatelogs这个工具，但是可以下载一个cronolog的软件，进入官方下载页面下载Win 32 version (ZIP file) 版本，将压缩包中的cronolog.exe解压缩到apache安装目录的bin目录下面，然后可以将CustomLog logs/access.log common 修改为： CustomLog &#34;&#124;bin/cronolog.exe logs/access%Y%m%d.log&#34; combined 这样可以达到同样的效果。需要说明的是再重启Apache之后原来的cronolog.exe进程不会自动关闭，这个应该是软件的bug。官方最新的更新日期是2002-01-24，而且最新的1.6.2 版本没有windows版本，所以要耐心等待了。 2. Resin日志 前段时间提到过因为Resin日志巨大的问题而导致出错，过了这几天又发现jvm.log文件达到1G的容量了，照这样下去如果忘记清空日志的话又会导致程序出错。无意间在一篇文章中看到这样一句话： Resin启动时通过bin目录下的wrapper.pl文件进行控制，我们可以修改这个文件来加一些参数…… 后来经过测试这样的启动方式是在Linux系统下，Windows下面修改这个文件是没有作用的。记得以前我在 Resin 3.x 经验总结文章中提到在Windows下设置jvm内存的时候可以使用下面的命令： httpd.exe -Xmn100M -Xms500M -Xmx500M 是不是上面提到的wrapper.pl文件中的httpd参数都可以这样设置呢？后来在Resin官方的新闻组里面找到了这个配置参数： You can use -jvm-log logfile as an option [...]]]></description>
			<content:encoded><![CDATA[<p>昨天服务器上网站无故无法访问，重启Apache之后过一段时间又无法访问。后来无意间看到Apache的日志文件(access.log)竟然有7G多，赶紧删除之再重启Apache就OK了。但是总是这样也不是办法，如果时间一长忘记清空日志文件的话又会造成Apache死掉，另外之前<a href="http://www.javatang.com/archives/2007/05/04/0353161.html">Resin也产生过这样的问题</a>。后来综合Google后的信息采用了如下的解决方法：</p>
<p><strong>1. Apache日志</strong><br />
减少日志大小有两种方法，一种是修改日志记录级别，可以将默认的warn级别提升为error级别；</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">LogLevel error</li></ol></div>
<p>另外一种方法就是将日志文件按照每天创建一个文件的方式产生，这样就不会将所有的信息写入到一个文件。在Linux下可以将 httpd.conf 中 CustomLog logs/access.log common 修改为：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">CustomLog &quot;|/usr/local/apache/bin/rotatelogs /usr/local/apache/logs/%Y_%m_%d.access.log 86400 480&quot; common</li></ol></div>
<p>Windows下没有rotatelogs这个工具，但是可以下载一个<a target="_blank" href="http://cronolog.org/">cronolog</a>的软件，进入官方<a target="_blank" href="http://cronolog.org/download/index.html">下载页面</a>下载Win 32 version (ZIP file) 版本，将压缩包中的cronolog.exe解压缩到apache安装目录的bin目录下面，然后可以将CustomLog logs/access.log common 修改为：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">CustomLog &quot;|bin/cronolog.exe logs/access%Y%m%d.log&quot; combined</li></ol></div>
<p>这样可以达到同样的效果。需要说明的是再重启Apache之后原来的cronolog.exe进程不会自动关闭，这个应该是软件的bug。官方最新的更新日期是2002-01-24，而且最新的1.6.2 版本没有windows版本，所以要耐心等待了。</p>
<p><strong>2. Resin日志</strong><br />
前段时间提到过因为Resin日志巨大的问题而导致出错，过了这几天又发现jvm.log文件达到1G的容量了，照这样下去如果忘记清空日志的话又会导致程序出错。无意间在<a target="_blank" href="http://dbalife.com/archives/archives/2007/03/resin.html">一篇文章中</a>看到这样一句话：</p>
<blockquote><p>Resin启动时通过bin目录下的wrapper.pl文件进行控制，我们可以修改这个文件来加一些参数……</p></blockquote>
<p>后来经过测试这样的启动方式是在Linux系统下，Windows下面修改这个文件是没有作用的。记得以前我在 <a href="http://www.javatang.com/archives/2006/08/21/010658.html">Resin 3.x 经验总结</a>文章中提到在Windows下设置jvm内存的时候可以使用下面的命令：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">httpd.exe -Xmn100M -Xms500M -Xmx500M</li></ol></div>
<p>是不是上面提到的wrapper.pl文件中的httpd参数都可以这样设置呢？后来在Resin官方的新闻组里面找到了这个配置参数：</p>
<blockquote><p>You can use -jvm-log logfile as an option to httpd.exe</p></blockquote>
<p>这样的话就可以设置Resin不产生jvm.log日志文件，因为里面的信息在web程序中通过log4j获得了。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">httpd -jvm-log NUL</li></ol></div>
<p>按照以下步骤重新按照Resin的NT服务：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#1 停止Resin NT服务和Apache</li>
<li>httpd -remove</li>
<li>#2 安装Resin NT服务</li>
<li>httpd -jvm-log NUL -install</li>
<li>#3 重新启动Resin和Apache</li></ol></div>
<p>参考资料：<br />
<a target="_blank" href="http://wanghgui.bokee.com/viewdiary.12339336.html">解决Apache日志文件ACCESS.LOG日益膨胀的一个办法</a><br />
<a target="_blank" href="http://www.caucho.com/support/resin-interest/0505/0069.html">jvm.log workarounds</a><br />
<a target="_blank" href="http://dbalife.com/archives/archives/2007/03/resin.html">resin的优化</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li><li><a href="http://www.javatang.com/archives/2010/11/14/1752494.html" rel="bookmark" class="crp_title">Resin中对日志输出的配置</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li><li><a href="http://www.javatang.com/archives/2008/01/22/0615259.html" rel="bookmark" class="crp_title">解决Apache出现的CPU高占用率的问题</a></li><li><a href="http://www.javatang.com/archives/2011/09/20/2831546.html" rel="bookmark" class="crp_title">Apache+Resin发布程序时一直出现403错误的解决办法</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2007/06/20/1513177.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Resin 频繁宕掉的原因</title>
		<link>http://www.javatang.com/archives/2007/05/04/0353161.html</link>
		<comments>http://www.javatang.com/archives/2007/05/04/0353161.html#comments</comments>
		<pubDate>Thu, 03 May 2007 18:03:53 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[JavaPlateform]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[最近一段时间Resin频繁的宕掉，大概运行一天左右网站就无法访问了。但是已经使用了有半年多了一直都很好，后来查看Resin的log目录的时候，在里面赫然发现有个jvm.log文件有1.6G。于是赶紧停止Resin然后删除之！！ 一般来说，如果一个软件使用很长时间突然出现问题，首先看日志文件！算是一个经验吧，呵呵 Related Posts:Apache和Resin组合时UrlRewriteFilter失效的解决方法Apache和Resin组合时间歇性出现503错误的解决方法Apache+Resin下如何写伪静态和301跳转Resin中对日志输出的配置Resin 3.0.x 经验总结]]></description>
			<content:encoded><![CDATA[<p class="storycontent">最近一段时间Resin频繁的宕掉，大概运行一天左右网站就无法访问了。但是已经使用了有半年多了一直都很好，后来查看Resin的log目录的时候，在里面赫然发现有个jvm.log文件有1.6G。于是赶紧停止Resin然后删除之！！</p>
<p>一般来说，如果一个软件使用很长时间突然出现问题，首先看日志文件！算是一个经验吧，呵呵</p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2010/08/27/3629451.html" rel="bookmark" class="crp_title">Apache和Resin组合时UrlRewriteFilter失效的解决方法</a></li><li><a href="http://www.javatang.com/archives/2010/11/13/1228487.html" rel="bookmark" class="crp_title">Apache和Resin组合时间歇性出现503错误的解决方法</a></li><li><a href="http://www.javatang.com/archives/2008/10/18/1942276.html" rel="bookmark" class="crp_title">Apache+Resin下如何写伪静态和301跳转</a></li><li><a href="http://www.javatang.com/archives/2010/11/14/1752494.html" rel="bookmark" class="crp_title">Resin中对日志输出的配置</a></li><li><a href="http://www.javatang.com/archives/2006/08/21/010658.html" rel="bookmark" class="crp_title">Resin 3.0.x 经验总结</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2007/05/04/0353161.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Resin 3.0.x 经验总结</title>
		<link>http://www.javatang.com/archives/2006/08/21/010658.html</link>
		<comments>http://www.javatang.com/archives/2006/08/21/010658.html#comments</comments>
		<pubDate>Mon, 21 Aug 2006 03:01:06 +0000</pubDate>
		<dc:creator>Jet</dc:creator>
				<category><![CDATA[JavaPlateform]]></category>
		<category><![CDATA[Web&Server]]></category>
		<category><![CDATA[resin]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[这两天正好项目刚刚完成，所以就好好的研究了下Resin。我用的Resin版本是3.0.19，中间遇到一些常见的问题，但是网上大多数的资料都是1.x或2.x的，在3.x中是不能使用的，所以查到解决的办法不是件容易的事情，现在整理出来与大家分享： 1. 怎样关闭目录浏览方式? 查了些资料，大多数都是说可以 将directory-servlet设置为 “none” 来禁止目录浏览，但是这种方式只是针对于Resin2.x，在3.x中已经不使用directory-servlet了。后来看了下官方的文档资料，原来关闭目录浏览的方法很简单，只需要将resin.conf中 &#60;servlet servlet-name=&#34;directory&#34;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; servlet-class=&#34;com.caucho.servlets.DirectoryServlet&#34;/&#62; 修改为 &#60;servlet servlet-name=&#34;directory&#34;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; servlet-class=&#34;com.caucho.servlets.DirectoryServlet&#34;&#62;&#160; &#160; &#160; &#160; &#160; &#160; &#60;init&#160;enable=&#34;false&#34;/&#62;&#160; &#160; &#160; &#160; &#60;/servlet&#62; 或者直接注释掉这一段代码就可以了。 2. 设置Servlet为默认首页 在web.xml中这样设置 &#60;servlet-mapping&#62; &#60;servlet-name&#62;MainPageServlet&#60;/servlet-name&#62; &#60;url-pattern&#62;/index&#60;/url-pattern&#62; &#60;/servlet-mapping&#62; &#60;welcome-file-list&#62; &#60;welcome-file&#62;index&#60;/welcome-file&#62; &#60;/welcome-file-list&#62; 如果这样的话在Tomcat中可以实现的，但是在Resin中会提示404。后来查了下资料，发现在Resin中默认的首页文件必须真实存在才可以的(”Point is that welcome file MUST [...]]]></description>
			<content:encoded><![CDATA[<p>这两天正好项目刚刚完成，所以就好好的研究了下Resin。我用的Resin版本是3.0.19，中间遇到一些常见的问题，但是网上大多数的资料都是1.x或2.x的，在3.x中是不能使用的，所以查到解决的办法不是件容易的事情，现在整理出来与大家分享：</p>
<p><strong>1. 怎样关闭目录浏览方式?</strong><br />
查了些资料，大多数都是说可以 将directory-servlet设置为 “none” 来禁止目录浏览，但是这种方式只是针对于Resin2.x，在3.x中已经不使用directory-servlet了。后来看了下官方的文档资料，原来关闭目录浏览的方法很简单，只需要将resin.conf中</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">servlet</span><span style="color: Gray;"> </span><span style="color: #00008b;">servlet-name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">directory</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">servlet-class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">com.caucho.servlets.DirectoryServlet</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span></li></ol></div>
<p>修改为</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">servlet</span><span style="color: Gray;"> </span><span style="color: #00008b;">servlet-name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">directory</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #00008b;">servlet-class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">com.caucho.servlets.DirectoryServlet</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">init</span><span style="color: Gray;">&nbsp;</span><span style="color: #00008b;">enable</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">false</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span><span style="color: Gray;">&nbsp;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">&lt;/</span><span style="color: Green;">servlet</span><span style="color: Olive;">&gt;</span></li></ol></div>
<p>或者直接注释掉这一段代码就可以了。</p>
<p><strong>2. 设置Servlet为默认首页</strong><br />
在web.xml中这样设置</p>
<blockquote><p>&lt;servlet-mapping&gt;<br />
  &lt;servlet-name&gt;MainPageServlet&lt;/servlet-name&gt;<br />
  &lt;url-pattern&gt;/index&lt;/url-pattern&gt;<br />
&lt;/servlet-mapping&gt;</p>
<p>&lt;welcome-file-list&gt;<br />
  &lt;welcome-file&gt;index&lt;/welcome-file&gt;<br />
&lt;/welcome-file-list&gt;</p></blockquote>
<p>如果这样的话在Tomcat中可以实现的，但是在Resin中会提示404。后来查了下资料，发现在Resin中默认的首页文件必须真实存在才可以的(”Point is that welcome file MUST exist on the server.”)，所以除了上述的设置之外还需要在网站跟目录下面创建一个同名的空文件就可以了。</p>
<p><strong>3. 安装Resin为WinNT服务</strong><br />
使用以下命令安装Resin为NT服务：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">httpd.exe -install</li></ol></div>
<p>卸载服务使用下面的命令：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">httpd.exe -remove</li></ol></div>
<p>这里需要说明的是：如果Apache和Resin组合的话，删除Resin的NT服务之前首先需要停止Apache，否则无法删除。</p>
<p><strong>4. 出现OutOfMemoryException的解决方法</strong><br />
出现OOM异常大多数是因为分配给Resin的内存过小造成的，这个时候可以使用以下命令增大Resin的内存：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">unix&gt; bin/httpd.sh -Xmn100M -Xms500M -Xmx500M </li>
<li>win&gt; httpd.exe -Xmn100M -Xms500M -Xmx500M </li>
<li>install win service&gt; httpd.exe -Xmn100M -Xms500M -Xmx500M -install</li></ol></div>
<p>这样就可以设置Resin使用的内存了</p>
<p><strong>5. Resin和Apache组合</strong><br />
我感觉Resin和Apache组合是最简单的，设置比Tomcat简单方便的多。总结一下可以使用如下步骤：<br />
1) 分别安装Apache和Resin<br />
2) 在Apache中的httpd.conf中添加模块，代码如下：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">LoadModule caucho_module &quot;yourResinHome/win32/apache-2.0/mod_caucho.dll&quot;</li></ol></div>
<p>3) 如果是同一IP的多个站点，可以将<br />
ResinConfigServer localhost 6802<br />
放到VirtualHost代码中，下面是一个例子：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">&lt;virtualhost *:80&gt; </li>
<li>ServerName www.3721.com </li>
<li>DocumentRoot &quot;C:\website\www&quot; </li>
<li>&nbsp; </li>
<li>ResinConfigServer localhost 6802 </li>
<li>&lt;/virtualhost&gt;</li></ol></div>
<p>当然如果想让虚拟站点正确运行的话，还需要在Resin的resin.conf文件中添加站点，具体可以参考Resin手册；如果不是同IP的虚拟站点，只要将 ResinConfigServer localhost 6802 放到任意一个地方就可以了</p>
<p>最后分别重启一下Resin和Apache就可以了，是不是很简单？</p>
<p>参考资料：<br />
Resin 3.0 官方文档</p>
<p>/RESIN/ welcome-files &amp; servlet<br />
<a target="_blank" href="http://groups.google.com/group/fido7.ru.java/browse_thread/thread/986b22abad39551c/8cd4cbffabd64fe1?lnk=st&amp;q=resin+servlet+welcome-file&amp;rnum=2#8cd4cbffabd64fe1">http://groups.google.com/group/fido7.ru.java/browse_thread/thread/986b22abad39551c/8cd4cbffabd64fe1?lnk=st&amp;q=resin+servlet+welcome-file&amp;rnum=2#8cd4cbffabd64fe1</a></p>
<div id="crp_related"><h2>Related Posts:</h2><ul><li><a href="http://www.javatang.com/archives/2010/08/27/3629451.html" rel="bookmark" class="crp_title">Apache和Resin组合时UrlRewriteFilter失效的解决方法</a></li><li><a href="http://www.javatang.com/archives/2006/10/20/254879.html" rel="bookmark" class="crp_title">DWR文档之开始使用 DWR</a></li><li><a href="http://www.javatang.com/archives/2007/06/20/1513177.html" rel="bookmark" class="crp_title">Apache和Resin产生大容量日志的解决办法</a></li><li><a href="http://www.javatang.com/archives/2008/07/07/5648271.html" rel="bookmark" class="crp_title">如何使用DWR2.0的注解功能</a></li><li><a href="http://www.javatang.com/archives/2006/04/24/400519.html" rel="bookmark" class="crp_title">Apache整合Tomcat之后的优化</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.javatang.com/archives/2006/08/21/010658.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.javatang.com @ 2012-02-10 07:31:48 -->
