<?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>聚沙成塔-小哈的记事薄 &#187; weblogic</title>
	<atom:link href="http://www.hashei.me/tag/weblogic/feed" rel="self" type="application/rss+xml" />
	<link>http://www.hashei.me</link>
	<description>一个系统工程师的絮叨</description>
	<lastBuildDate>Tue, 10 Jan 2012 18:03:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type='text/javascript' src='http://hashei.me/wp-includes/js/jquery/jquery.js?ver=1.3.2'></script>
<script type="text/javascript">
/* <![CDATA[ */
jQuery.ajax({type:'GET',url:'http://hashei.me/wp-content/plugins/wp-postviews-plus/postviews_plus.php',data:'todowppvp=add&type=tag&id=139_1',cache:false,dataType:'script'});
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>如何在一台服务器上部署多个相同url的应用？</title>
		<link>http://www.hashei.me/2009/12/use_same_context_root_for_different_application_on_one_server.html?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=use_same_context_root_for_different_application_on_one_server</link>
		<comments>http://www.hashei.me/2009/12/use_same_context_root_for_different_application_on_one_server.html#comments</comments>
		<pubDate>Tue, 15 Dec 2009 14:16:00 +0000</pubDate>
		<dc:creator>hashei</dc:creator>
				<category><![CDATA[websphere初级技术]]></category>
		<category><![CDATA[weblogic]]></category>
		<category><![CDATA[虚拟主机]]></category>

		<guid isPermaLink="false">http://www.hashei.me/2009/12/use_same_context_root_for_different_application_on_one_server.html</guid>
		<description><![CDATA[现在的服务器性能越来越强，内存动辄4G、8G，而32位JDK下，单个java堆一般不超过1.7G。那多出来的内存怎么办？建垂直集群（Vertical clusters：垂直集群是指同一机器上部署多个服务器，充分利用硬件资源）可以，简单的部署多个appserver也行。但是应用如何处理？如果多个项目都需要用相同的context root，比如说/，那怎么办？
其实做过网站的朋友都知道，一台服务器上一般不可能只放一个网站，那如何访问到这些网站，有三种方法：

IP不同，一个网卡上绑定多个IP，不同的IP对应不同的网站。
端口不同，不同的网站运行在不同的端口上。
虚拟主机不同，通过不同的虚拟主机名（一般都是域名）来访问。

那对于webshpere或者weblogic，很明显可以实行的是上述第三种方案。部署应用时会让我们选择部署到哪台虚拟主机，默认的都为default host，所以我们只要新建一个虚拟主机，名称一般为域名。那么就能实现通过一级域名直接访问应用。即使一台app server上部署了多个应用。
这种设置对于提供互联网服务的应用尤其有效，因为大家本来就是通过域名来访问的。而且即使只有一个应用，设置非默认的虚拟主机名可以起到只能通过域名来访问，而IP地址访问则会得到应用服务找到的错。虽说提高的安全性不多，但能满足年底全市各部门关于“只能通过域名访问，而IP无法访问”的要求。
至于内网用户，可以在内部dns上配置域名解析，或者编写hosts文件，达到同样效果。
更新：对于webshpere，我测试下来即使不同的虚拟主机，相同的上下文根也无法同时启动。在日志里会看到已经有重复的Context root了，这样的话只能配置apache使用它的虚拟主机解决
  Copyright &#169; 2008 This feed is for personal, non-commercial use only
聚沙成塔-小哈的记事薄 by hashei 
如果喜欢，欢迎订阅feed.hashei.com
Digital Fingerprint:
 10f920a9f2bae51c3c73c4f5fb50a949]]></description>
			<content:encoded><![CDATA[<p>现在的服务器性能越来越强，内存动辄4G、8G，而32位JDK下，<a title="IBM JDK下websphere jvm堆的优化" href="http://www.hashei.me/2009/05/tuning-the-ibm-jdk.html" target="_blank">单个java堆一般不超过1.7G</a>。那多出来的内存怎么办？建垂直集群（Vertical clusters：垂直集群是指同一机器上部署多个服务器，充分利用硬件资源）可以，简单的部署多个appserver也行。但是应用如何处理？如果多个项目都需要用相同的context root，比如说/，那怎么办？</p>
<p>其实做过网站的朋友都知道，一台服务器上一般不可能只放一个网站，那如何访问到这些网站，有三种方法：</p>
<ol>
<li>IP不同，一个网卡上绑定多个IP，不同的IP对应不同的网站。</li>
<li>端口不同，不同的网站运行在不同的端口上。</li>
<li>虚拟主机不同，通过不同的虚拟主机名（一般都是域名）来访问。</li>
</ol>
<p>那对于webshpere或者weblogic，很明显可以实行的是上述第三种方案。部署应用时会让我们选择部署到哪台虚拟主机，默认的都为default host，所以我们只要新建一个虚拟主机，名称一般为域名。那么就能实现通过一级域名直接访问应用。即使一台app server上部署了多个应用。</p>
<p>这种设置对于提供互联网服务的应用尤其有效，因为大家本来就是通过域名来访问的。而且即使只有一个应用，设置非默认的虚拟主机名可以起到只能通过域名来访问，而IP地址访问则会得到应用服务找到的错。虽说提高的安全性不多，但能满足年底全市各部门关于“只能通过域名访问，而IP无法访问”的要求。</p>
<p>至于内网用户，可以在内部dns上配置域名解析，或者编写hosts文件，达到同样效果。</p>
<p>更新：对于webshpere，我测试下来即使不同的虚拟主机，相同的上下文根也无法同时启动。在日志里会看到已经有重复的Context root了，这样的话只能配置apache使用它的虚拟主机解决</p>
<hr /><small>  Copyright &copy; 2008 This feed is for personal, non-commercial use only<br />
<a href=www.hashei.com >聚沙成塔-小哈的记事薄</a> by hashei 
如果喜欢，欢迎订阅<a href=feed.hashei.com >feed.hashei.com</a><br />
Digital Fingerprint:
 10f920a9f2bae51c3c73c4f5fb50a949</small>]]></content:encoded>
			<wfw:commentRss>http://www.hashei.me/2009/12/use_same_context_root_for_different_application_on_one_server.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>官方JRockit JVM调优文档</title>
		<link>http://www.hashei.me/2009/09/weblogic_profiling_and_performance_tuning.html?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=weblogic_profiling_and_performance_tuning</link>
		<comments>http://www.hashei.me/2009/09/weblogic_profiling_and_performance_tuning.html#comments</comments>
		<pubDate>Mon, 07 Sep 2009 00:38:51 +0000</pubDate>
		<dc:creator>hashei</dc:creator>
				<category><![CDATA[中间件]]></category>
		<category><![CDATA[jrockit]]></category>
		<category><![CDATA[weblogic]]></category>
		<category><![CDATA[性能优化]]></category>

		<guid isPermaLink="false">http://www.hashei.me/2009/09/weblogic_profiling_and_performance_tuning.html</guid>
		<description><![CDATA[转自BEA，原文链接已经无法访问，文中的许多链接也更改过地址，我把能找到的都重新做了连接。以前一直以为Jrockit和Sun的JVM配置差不多，看了这篇文章和最后参考资料中的信息，发现区别不是一点点，很多常用参数的使用都不一样。Jrockit的自动化设置应该说做的不错，在WebLogic上我很少更改它的默认配置（除了堆最大最小值），不过不影响这篇文章存在的价值。
摘要
 本文的目的是以清单的方式提供BEA JRockit JVM的调优信息。从深奥的命令行选项到迭代性能测试，本文涵盖了许多方面。大部分数据都是我与用户合作过程中收集的。您要是也有什么技巧的话，请告诉我，在本文的下一版中，我会尝试将它们添加进去。 
 具体的产品版本信息都已在适当的地方列出；但是，本文所提供的通用指南适用于JRockit的大多数版本。每个版本的JRockit都增加了新的设置和优化，所以请查看 发行说明 和 JRockit产品中心。 
验证当前的JRockit环境
 首先需要确定您的运行时应用程序服务器所使用的JRockit的版本。为此，可以查看相应应用程序服务器的日志文件。也可以使用适当的脚本设置系统环境，然后执行java &#8211;version命令来确定JRockit的版本。 
 接着，收集当前JVM标志，开发和/或生产阶段需要用到它们：
-server -Xms1024m -Xmx1536m -Xverboselog:gc.log -Xverbose:memory-Xgcprio:throughput
 这将告诉您当前JRockit实例的配置情况。 
确定应用程序的目标
 确定应用程序的目标是什么。是&#8220;响应快&#8221;还是&#8220;性能高&#8221;？根据目标的不同，需要设置不同的垃圾收集算法。 
 例如，如果应用程序的目标是实现高性能，则确保设置了Dynamic Garbage Collector &#34;-Xgcprio:throughput&#34; 选项。如果目标是响应时间短，那么需要将-Xgcprio:pausetime -Xpausetarget=XXX&#8217;中的pausetarget设置为最佳值。有关更多细节，请查看JRockit 调优文档。 
收集故障诊断数据
 如果JVM性能有问题，那么最好是先收集一些分析数据。该工作可以由团队中有相关经验的人员来完成，您也可以将这些信息发送给BEA Support做进一步分析。 
 首先，出现问题时需要收集大约10分钟的运行时JRockit Recording（JRA)数据。可以使用jrcmd.sh实用工具或JRockit Mission Control（JRMC）完成此操作。请阅读&#8220;性能测试期间的JRCMD/JRA&#8221;和&#8220;JRockit Mission Control&#8221;两节的内容。有关详细信息，请参阅 JRockit Mission Control文档。Latency Analysis一节提供许多有价值的内容，我们可以从中了解任何潜在的延迟问题（在JRockit中需要一个许可证就可以使用它）。 
 然后，需要收集问题发生时的一些详细日志。方法是在启动服务器实例的时候在JVM命令行输入以下参数：
-Xverboselog:perTestGC.log-Xverbose:opt,memory,gcpause,memdbg,compaction,gc,license-Xverbosetimestamp -Xgcreport
 这样会将有价值的分析数据收集到刚才配置的perTestGC.log文件中。团队成员和/或BEA Support可以对这些数据进行分析。 
 最后一点：通常，应用程序不会请求执行垃圾收集（也就是在应用程序代码中调用System.gc()）。但如果您怀疑它有问题，那么可以在启动服务器实例的时候，在Java命令行使用-XXnoSystemGC参数来禁用它。 
 现在，我将介绍如何通过迭代性能测试方法解决这些问题。 

迭代性能测试方案及其方法
 完成初始数据的收集和分析后，我们可以通过迭代方法来调优JVM。此处介绍的测试方案是在JRockit JVM层执行迭代调优的通用方法，可以找到哪些设置可能有益于特定应用程序。假定您有测量性能结果的方法；然后，可以将它们与&#8220;基准&#8221;（您应该已经有了） [...]]]></description>
			<content:encoded><![CDATA[<p style="text-indent: 24pt">转自BEA，原文链接已经无法访问，文中的许多链接也更改过地址，我把能找到的都重新做了连接。以前一直以为Jrockit和Sun的JVM配置差不多，看了这篇文章和最后参考资料中的信息，发现区别不是一点点，很多常用参数的使用都不一样。Jrockit的自动化设置应该说做的不错，在WebLogic上我很少更改它的默认配置（除了堆最大最小值），不过不影响这篇文章存在的价值。</p>
<h5>摘要</h5>
<p> 本文的目的是以清单的方式提供BEA JRockit JVM的调优信息。从深奥的命令行选项到迭代性能测试，本文涵盖了许多方面。大部分数据都是我与用户合作过程中收集的。您要是也有什么技巧的话，请告诉我，在本文的下一版中，我会尝试将它们添加进去。 </p>
<p> 具体的产品版本信息都已在适当的地方列出；但是，本文所提供的通用指南适用于JRockit的大多数版本。每个版本的JRockit都增加了新的设置和优化，所以请查看 <a title="Jrockit发行说明" href="http://download.oracle.com/docs/cd/E13188_01/jrockit/jrdocs/index.html">发行说明</a> 和 <a title="JRockit产品中心" href="http://download.oracle.com/docs/cd/E13188_01/jrockit/webdocs/index.html">JRockit产品中心</a>。 </p>
<h5>验证当前的JRockit环境</h5>
<p> 首先需要确定您的运行时应用程序服务器所使用的JRockit的版本。为此，可以查看相应应用程序服务器的日志文件。也可以使用适当的脚本设置系统环境，然后执行java &#8211;version命令来确定JRockit的版本。 </p>
<p> 接着，收集当前JVM标志，开发和/或生产阶段需要用到它们：</p>
<pre>-server -Xms1024m -Xmx1536m -Xverboselog:gc.log -Xverbose:memory-Xgcprio:throughput</pre>
<p> 这将告诉您当前JRockit实例的配置情况。 </p>
<h5>确定应用程序的目标</h5>
<p> 确定应用程序的目标是什么。是&#8220;响应快&#8221;还是&#8220;性能高&#8221;？根据目标的不同，需要设置不同的垃圾收集算法。 </p>
<p> 例如，如果应用程序的目标是实现高性能，则确保设置了Dynamic Garbage Collector &quot;-Xgcprio:throughput&quot; 选项。如果目标是响应时间短，那么需要将-Xgcprio:pausetime -Xpausetarget=XXX&#8217;中的pausetarget设置为最佳值。有关更多细节，请查看JRockit <a href="http://download.oracle.com/docs/cd/E13188_01/jrockit/geninfo/diagnos/part_02.html">调优文档</a>。 </p>
<h5>收集故障诊断数据</h5>
<p> 如果JVM性能有问题，那么最好是先收集一些分析数据。该工作可以由团队中有相关经验的人员来完成，您也可以将这些信息发送给BEA Support做进一步分析。 </p>
<p> 首先，出现问题时需要收集大约10分钟的运行时JRockit Recording（JRA)数据。可以使用jrcmd.sh实用工具或<a title="JRMC" href="http://download.oracle.com/docs/cd/E13188_01/jrockit/geninfo/diagnos/intromiscon.html">JRockit Mission Control</a>（JRMC）完成此操作。请阅读&#8220;性能测试期间的JRCMD/JRA&#8221;和&#8220;JRockit Mission Control&#8221;两节的内容。有关详细信息，请参阅 <a href="http://download.oracle.com/docs/cd/E13188_01/jrockit/tools/index.html">JRockit Mission Control文档</a>。Latency Analysis一节提供许多有价值的内容，我们可以从中了解任何潜在的延迟问题（在JRockit中需要一个许可证就可以使用它）。 </p>
<p> 然后，需要收集问题发生时的一些详细日志。方法是在启动服务器实例的时候在JVM命令行输入以下参数：</p>
<pre>-Xverboselog:perTestGC.log-Xverbose:opt,memory,gcpause,memdbg,compaction,gc,license-Xverbosetimestamp -Xgcreport</pre>
<p> 这样会将有价值的分析数据收集到刚才配置的perTestGC.log文件中。团队成员和/或BEA Support可以对这些数据进行分析。 </p>
<p> 最后一点：通常，应用程序不会请求执行垃圾收集（也就是在应用程序代码中调用System.gc()）。但如果您怀疑它有问题，那么可以在启动服务器实例的时候，在Java命令行使用-XXnoSystemGC参数来禁用它。 </p>
<p> 现在，我将介绍如何通过迭代性能测试方法解决这些问题。 </p>
<p><span id="more-660"></span></p>
<h5>迭代性能测试方案及其方法</h5>
<p> 完成初始数据的收集和分析后，我们可以通过迭代方法来调优JVM。此处介绍的测试方案是在JRockit JVM层执行迭代调优的通用方法，可以找到哪些设置可能有益于特定应用程序。假定您有测量性能结果的方法；然后，可以将它们与&#8220;基准&#8221;（您应该已经有了） 进行比较。 </p>
<h5>测试1：线程本地区域大小和大对象大小</h5>
<p> 在本测试中，我们将查看线程本地区域大小。这很重要，因为如果这些标志的默认设置对于应用程序不是最佳的（多数情况下是这样），那么就会造成堆锁定，这将对性能产生影响。将大部分对象限制在一定范围内对整体性能有益。 </p>
<ul>
<li>分析收集的JRA Recording数据</li>
</ul>
<ul>
<li>分析结果，查看-XXtlasize和-XXlargeobjectlimit是否需要调优（请记住，对于多数应用程序，根据eDocs，线程本地区域大小应该至少是大对象大小的两倍）。这些内容位于JRA Recording首页的右上方。请查看下面关于 <a href="http://edocs.bea.com/jrockit/jrdocs/refman/optionXX.html#wp1020097">tlaSize</a> 和<a href="http://edocs.bea.com/jrockit/jrdocs/refman/optionXX.html#wp1008230">largeObjectLimit</a> 的信息。在JRockit R27.3之前的多数情况下，这些都不必调优。</li>
</ul>
<p><strong>注意：</strong>为了确保在稳定状态下获取配置文件和度量，应用程序需要有足够的热启动时间。要在性能分析过程中检查是否符要求，可以查看JRA Recording中的优化标签，其中性能分析前后的优化数量和优化时间应该大致（理论上应该是准确地）相等。 </p>
<h5>测试2：锁性能分析</h5>
<p> 现在让我们看一下锁性能分析，它会显示在应用程序中是否有过多的锁定。如果确实如此的话，那么将对整体性能造成影响。 </p>
<ul>
<li>运行测试（启用-Djrockit.lockprofiling），分析这些结果。确定没有通过JVM启用的日志。该标志大概会占用5%到10%的系统开销，一个单独的测试将收集该数据，此时性能被忽略，唯一做完的分析是锁定分析。</li>
</ul>
<pre>-server -Xms1536m -Xmx1536m <strong>-Djrockit.lockprofiling</strong></pre>
<ul>
<li>在相同测试中，使用jrcmd.sh实用工具或JRockit Mission Control（JRMC）热启动应用程序后，运行10分钟的JRA Recording。有关如何使用该工具的信息，请参见电子文档。 </li>
<li>使用top和iostat选项监控操作系统，如果需要的话还可使用ctrhandler.act文件指定的信息执行线程转储。 </li>
<li>分析结果。</li>
</ul>
<h5>测试3：调优tlaSize和largeObjectLimit</h5>
<p> 在这个测试中，我们将根据前面测试的结果调优线程本地区域大小和大对象限制。 </p>
<ul>
<li>确定JVM未启用日志。将 &#8211;XxtlaSize和-XXlargeObjectLimit的值设置较高一点可能会有所帮助。但是，要验证和比较这点则需要需要长时间运行测试。对于 R27.2，将preferredSize设置为16k可能有所帮助。您可以查看关于这一问题的 <a href="http://edocs.bea.com/jrockit/geninfo/conftune/issues.html#wp999214">详细信息</a>。为此要，更改TLA设置并使用与测试1相同的Java命令行选项重新运行测试；增加-XXtlaSize和-XXlargeobjectlimit的TLA值设置。相关信息，请<a href="http://edocs.bea.com/jrockit/jrdocs/refman/optionXX.html#wp1020097">参见 tlaSize</a>。<strong>注意：</strong>在R27.3之前，提高性能通常不需要调优这些标志。事实上，过度调优这些标志很可能带来负面影响。 </li>
<li>在相同测试中，使用jrcmd.sh实用工具或JRockit Mission Control（JRMC）热启动应用程序后，运行10分钟的JRA Recording。关于如何使用该工具的信息，请参见电子文档。</li>
</ul>
<ul>
<li>使用top和iostat选项监控操作系统，如果需要的话还可使用ctrhandler.act文件指定的信息执行线程转储。</li>
</ul>
<ul>
<li>分析结果。</li>
</ul>
<h5>测试4：调优垃圾收集算法</h5>
<p> 本节测试的目的是运行各种不同的垃圾收集算法设置，并查看哪种设置对于应用程序最佳。关于 <a href="http://edocs.bea.com/jrockit/jrdocs/refman/optionXX.html#wp999595">-XXsetGC标志</a> 的详细令牌，请阅读以下内容。JRockit将以调优的nursery大小运行并移除-Xgcprio:throughput标志。该 throughput选项将在这些双版本的垃圾收集器之间自动切换，但进行直接的选择可能带来一些额外的性能上的好处。Nursery调优的目的是使被提 升的对象保持较少的数量，因为这是nursery收集中代价高的部分。通过增加和减小nursery的大小对其调优。nursery的大小主要依赖于对象 生存的时间，因为如果它们生存着，则在YC期间会得到提升。运行jrcmd &lt;PID&gt;版本查看哪个当前垃圾收集器策略是活动的。 </p>
<ul>
<li>a. 测试4-1：</li>
</ul>
<ul>
<ul>
<li>使用&#8211;XxsetGC垃圾收集算法设置运行测试。该测试将设置垃圾收集选项为<strong>单倍行距</strong>加上<strong>并行</strong>标记算法和<strong>并行</strong>扫描算法；还要手动调优nursery大小：</li>
</ul>
</ul>
<pre>-server -Xms1536m -Xmx1536m -Xns:384m&#160; -Xverboselog:perTestGC.log-Xverbose:opt,memory,gcpause,memdbg,compaction,gc,license-Xverbosetimestamp -Xgcreport -XXnoSystemGC -XXsetGC:<strong>singleparpar</strong></pre>
<ul>
<ul>
<li>在相同测试中，使用jrcmd.sh实用工具或JRockit Mission Control（JRMC）热启动应用程序后，运行10分钟的JRA Recording。关于如何使用该工具的信息，请参见电子文档。 </li>
<li>使用top和iostat选项监控操作系统，如果需要的话还可使用ctrhandler.act文件指定的信息执行线程转储。 </li>
<li>分析结果。</li>
</ul>
</ul>
<ul>
<li>b. 测试4-2：</li>
</ul>
<ul>
<ul>
<li>用 &#8211;XxsetGC运行一个使用垃圾收集算法集的测试。该测试将设置垃圾收集选项为<strong>分代</strong>的（双倍行距）加上<strong>并行</strong>标记算法和<strong>并行</strong>扫描算法；还要手动调优nursery大小：</li>
</ul>
</ul>
<pre>-server -Xms1536m -Xmx1536m -Xns:384m&#160; -Xverboselog:perTestGC.log</pre>
<pre>-Xverbose:opt,memory,gcpause,memdbg,compaction,gc,license</pre>
<pre>-Xverbosetimestamp -Xgcreport -XXnoSystemGC -XXsetGC:<strong>genparpar</strong></pre>
<ul>
<ul>
<li>在做这个测试的时候，使用jrcmd.sh实用工具或JRockit Mission Control (JRMC)收集应用程序热启动并运行后10分钟的JRA Recording。关于如何使用该工具，请参见eDocs。 </li>
<li>使用top、iostat，需要的话，还可用带有ctrhandler.act文件给定的信息的线程转储来监控正在运行的系统。 </li>
<li>分析结果。</li>
</ul>
</ul>
<ul>
<li>c. 测试4-3：根据前面的-XXsetGC:genparpar测试向上或向下调优nursery大小。 </li>
<li>d. 测试4-4：用-Xgc:gencon -Xns50m（和设为收集规格的日志）试试。 </li>
<li>e. 测试4-5：用-Xgc:parallel -XXcompactratio:1（和设为收集规格的日志）试试。</li>
</ul>
<h5>测试5：调优垃圾收集线程</h5>
<p> 本测试的目的是查看gcthreads标志设置对整体性能的影响。 </p>
<ul>
<li>根据前面的结果，调优-XXgcthreads标志为实际物理CPU的数量并重新运行测试(由于这些值默认是基于机器上核心和硬件线程的数量，所以这应该是自动调优的)。您可以查看在&#8220;收集故障诊断数据&#8221;一节收集的详细输出日志来对其验证。更多细节请参见 <a href="http://edocs.bea.com/jrockit/jrdocs/refman/optionXX.html#wp1023988">gcThreads flag</a>。</li>
</ul>
<h5>测试6：调优锁争用</h5>
<p> 如果在胖锁（fat lock）上存在锁争用，则可以用-XXdisableFatSpin禁止它们，或者用-Djrockit.useAdaptiveFatSpin= true让JRockit自适应地禁止它们。当测试2启用-Djrockit.lockprofiling时，可以通过在JRA中查看那个标签来确定这一 点。更多细节，请参见<a href="http://e-docs.bea.com/jrockit/geninfo/diagnos/thread_basics.html#wp1091168">locking in JRockit</a>。 </p>
<h5>测试7：调优Xeon硬件</h5>
<p> 如果运行在Xeon硬件之上，那么可以添加-XXallocPrefetch和-XXallocRedoPrefetch，它们与TLA和LargeObjectLimit一起将有助于减少内存分配的开销。有关详细信息，请参见 <a href="http://edocs.bea.com/jrockit/jrdocs/refman/optionXX.html#wp1023657">allocPrefetch标志</a>。为了得到最佳的结果，您可能会在BIOS中<strong>禁用</strong>硬件预取指令。虽然操作方式取决于BIOS的牌子，但参数的名称通常都为&#8220;Hardware Prefetcher&#8221;、&#8220;Adjacent Sector Prefetcher&#8221;、&#8220;Adjacent Cache Line Prefetcher&#8221;等。更多信息请参见 <a href="http://www.intel.com/cd/ids/developer/asmo-na/eng/dc/xeon/298229.htm?page=4">Intel on this subject</a>。 </p>
<h5>测试8：将堆放入largePage</h5>
<p> 这会将堆锁入内存，使操作系统不能将其交换出来。更多信息请参见 <a href="http://edocs.bea.com/jrockit/jrdocs/refman/optionXX.html#wp1019120">largePages标志</a>，有关Linux操作系统端配置的更多信息还可以参考 <a href="http://dev2dev.bea.com.cn/techdoc/2008/4/jrockit-tuning.html.html?page=3#linux">在Linux上配置-XXlargePages</a> 一节。在JRockit R27版中，该选项的名称为-XlargePages。根据前面的结果，调优-XlargePages标志可能有所帮助，但可能也没有。使用该标志运行测试，查看结果否对整体性能有帮助。 </p>
<h5>测试9：用-XXaggressive标志测试</h5>
<p> 本节中的这些配置将使JVM高速运行并尽快达到稳定状态。为了实现此目标，JVM在启动时需要更多内部资源；但当目标一旦达成，它所需要的自适应优化将更少。我们推荐您为了那些单独工作的、运行时间长的、内存敏感的应用程序使用这个选项。更多细节请参见 <a href="http://edocs.bea.com/jrockit/jrdocs/refman/optionXX.html#wp999550">aggressive标志</a>。使用-XXaggressive标志运行测试，查看结果否对整体性能有帮助。 </p>
<h5>测试10：用-XX:+UseNewHashFunction标志测试</h5>
<p> 这个选项支持一个新的、更快的HashMap散列函数，它在Java 5.0 Update 8中引入，从R27.1.0开始也是BEA JRockit的一部分。这个散列函数能够通过改进的散列扩展提高性能而不改变HashMap中元素存放的顺序。更多细节请参见<a href="http://edocs.bea.com/jrockit/jrdocs/refman/optionXX.html#wp1028966">UseNewHashFunction标志</a>。使用这个新的-XX:+UseNewHashFunction运行测试，，查看结果否对整体性能有帮助。 </p>
<h5>测试11：将暗物质减到最少</h5>
<p> &#8220;暗物质&#8221;指被浪费的堆内存，它使堆成为许多碎片。了解如何最大程序地减少暗物质，以便当堆需要压缩时，整体吞吐量不受影响。请看以下选项： </p>
<ul>
<li>使用分代的垃圾收集器 (-Xgc:gencon or -Xgc:genpar)。在初始收集（nursery垃圾收集）期间，在nursery中被发现生存的对象被迁移到旧的一代。这样有好的副作用，当迁移对象时可以压缩它们。 </li>
<li>提高压缩比（-XXcompactionRatio=nn）。通过将对象迁移到压缩块中、消除它们之间的暗物质，压缩减少了暗物质。 </li>
<li>通 过-XXminBlockSize:&lt;memSize&gt;选项修改规范（将什么视为暗物质？）。堆上小于最小块大小的块视为暗物质。因此，通过 减小最小块大小，您最终减少了暗物质。但请注意，因为JRockit为了释放堆空间必须做更细密的搜索，所以垃圾收集的时间会更长。最小块大小默认为2 KB。</li>
</ul>
<h5>进一步测试：调优应用程序服务器层</h5>
<p> 最后，查看上述调优建议，调优WebLogic Server实例层。 </p>
<h5>结束语</h5>
<p> 本文提供的信息绝非一个完整的清单。但它会让您开始更好地理解和调优JRockit JVM层！ </p>
<h5>参考资料</h5>
<ul>
<li><a href="http://download.oracle.com/docs/cd/E13188_01/jrockit/geninfo/diagnos/part_02.html">JRockit调优文档</a> </li>
<li><a href="http://download.oracle.com/docs/cd/E13188_01/jrockit/jrdocs/refman/optionX.html">JRocikit参考文档：X Flags</a> </li>
<li><a href="http://download.oracle.com/docs/cd/E13188_01/jrockit/jrdocs/refman/optionXX.html">JRocikit参考文档：XX Flags</a> </li>
</ul>
<h5>附录</h5>
<p> 以下内容为正文引用过的额外信息。 </p>
<h5>性能测试期间的JRCMD/JRA</h5>
<p> 使用命令行或者基于JRockit Mission Control (JRMC) Eclipse的工具都能够执行JRA Recoding。我们可以使用JRMC连接到多个 JRockit JVM，收集JRA recording，查看JVM的实时数据，检测和排除内存泄漏，以及查看应用程序内的潜伏物（执行缓慢&#8220;点&#8221;）。有关如何运行JRockit Mission Control，请参见下一节。 </p>
<ul>
<li>下载 <a href="http://commerce.bea.com/downloadproduct.jsp?family=JRMC&amp;major=3.0&amp;minor=0&amp;delivery=1&amp;os=All&amp;intent=purchase">文档许可证</a>。 </li>
<li>将下载的license.bea文件添加到&lt;JROCKIT_HOME&gt;/jre目录中。这样，完整路径将如下所示：&lt;JROCKIT_HOME&gt;/jre/license.bea </li>
<li>运 行JRCMD如下：jrcmd.sh &lt;PID&gt; jrarecording filename=myrecording.xml time=600（该文件被写入本地目录或者指定的完整路径／文件名）或jrcmd.sh &lt;PID&gt; print_threads。 </li>
<li>使用脱机JRA工具分析最后得到的myrecording.xml.zip文件。通过在&lt;JROCKIT_HOME&gt;/bin中执行JRA binary，将该JRA工具放入此目录下。 </li>
<li>请查看 <a href="http://e-docs.bea.com/jrockit/geninfo/diagnos/ctrlbreakhndlr.html#wp1000350">JRCMD文档</a>。</li>
</ul>
<h5>JRockit Mission Control</h5>
<ul>
<li>使用JRockit将下列内容添加到WebLogic Instance的启动行中：java -Xmanagement:autodiscovery=true,ssl=false,authenticate=false,port=7091 </li>
<li>使用&lt;jrockit-install-directory&gt;/bin/jrmc.exe(sh)启动JRockit Mission Control </li>
<li>如有必要，将JR Mission Control的license.bea file文件添加到：&lt;JROCKIT_HOME&gt;/jre/license.bea </li>
<li>在Mission Control的帮助下，JRA Recordings、内存泄漏、潜伏物探查和监控能够全部在一处完成。</li>
</ul>
<h5>堆/线程的测试期快照</h5>
<ul>
<li>创建一个简单的、名称ctrhandler.act的文件并将其存放在&lt;JROCKIT_HOME&gt;/jre/bin/jrockit目录。 </li>
<li>执行线程转储命令时，例如，kill -3)，JRockit会查看此文件并执行命令列表。 </li>
<li>ctrlhandler.act文件应该包含以下内容：</li>
</ul>
<pre>#ctrlhander.act file located in the &lt;JROCKIT_HOME&gt;/jre/bin/jrockit directoryset_filename filename=./jrocket_control_breakoutput.txt append=truetimestampprint_threadstimestampversionprint_class_summaryprint_object_summary increaseonly=trueprint_threadsprint_threads nativestack=trueprint_utf8pooltimestampprint_memusagetimestampheap_diagnosticstimestamp# The following is optional and is another way to generate a JRArecordingjrarecording filename=./myjra.xml time=600</pre>
<h5><a name="linux"></a>在Linux上配置-XXlargePages</h5>
<p><strong>问题：</strong>为何使用largePages？ </p>
<p><strong>回答：</strong>使用largePages的优点是可以锁定堆内存，并且不适用页面交换（还可以减少IOWait和GC）。在实际内存中，访问堆中的对象明显变快了。因此，为了实现性能目标，largePages选项是一个理想的选择。 </p>
<ul>
<li>如果机器支持大页面，则cat /proc/meminfo的输出将如下所示：</li>
</ul>
<pre>HugePages_Total: xxxHugePages_Free:&#160; yyyHugepagesize:&#160;&#160;&#160; zzz KB</pre>
<p> 如果xxx为0，则没有分配任何大页面。 </p>
<ul>
<li>如果不为0，则需要使用CONFIG_HUGETLBFS(位于&#8220;File systems&#8221;下面)和CONFIG_HUGETLB_PAGE（当CONFIG_HUGETLBFS被选时，自动被选上）配置选项构建Linux kernel。 </li>
<li>接着，在Linux上分配大页。注意：只允许根用户分配大页面。
<ul>
<li>装载文件系统。JRockit使用hugepages文件系统，它驻留在内存中。这些步骤可以完成文件系统的安装。每次机器重启时都需要完成实际装载和chmod命令，或者也可以将其添加到一个/etc/rc.d/rc.local类型的文件：</li>
</ul>
</li>
</ul>
<pre>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mkdir -p&#160; /mnt/hugepages&#160;&#160;&#160;&#160;&#160;&#160;&#160; mount -t hugetlbfs nodev /mnt/hugepages&#160;&#160;&#160;&#160;&#160;&#160;&#160; chmod 777 /mnt/hugepages</pre>
<ul>
<ul>
<li>分配大页面。这是通过指定应该分配的内存数量来自动执行的。在分配过程中，这些面页将被保留起来，不能像普通页面那样使用。它们的分配和解除分配方式如下：</li>
</ul>
</ul>
<pre>echo 20 &gt; /proc/sys/vm/nr_hugepages</pre>
<p> 此处，数字20指应该保留的页面数量。要解除分配，可以将分配页面设置为0。（<strong>注意：</strong>请参见后面Q&amp;A部分以确定正确的数量。） </p>
<p> 如果并非所有请求的页面都被保留，那么可用内存就不够了。如果确要如此，内存很可能会有太多的碎片，那么我们的建议是重启机器。请注意，大页面不能被交换，所以一切都必须放在物理内存中。 </p>
<p> 在<strong>RHEL3</strong>上，该文件的名称为/proc/sys/vm/hugetlb_pool，所以可以使用以下命令执行：</p>
<pre>echo 500 &gt; /proc/sys/vm/hugetlb_pool</pre>
<p> 这里的数字500指请求的大小为多少MB，而不是页数。如果JRockit不能够直接消除临时的大页文件，请别忘记在执行之后进行消除。否则， 那些页在被释放之前将不可用。这对RedHat kernel build 2.4.18-e.25.smp适用，而2.4.18-e.12.smp却不行。 </p>
<p><strong>问题：</strong>如何确定发给/proc/sys/vm/nr_hugepages的正确数量呢？ </p>
<p><strong>回答：</strong>因为要将整个Java堆放入largePages，所以必须根据堆的大小和页面大小来确定。为/proc/sys/vm/nr_hugepages确定正确的数量就像下面的例子那样简单，信息如下：</p>
<pre>JVM Max Heap = 1536MB (1572864 KB approx)HPAGE_SIZE = 2 MB then  the value sent to /proc/sys/vm/nr_hugepages would be approximately 7.7.  (1572864 MB / 2 MB)</pre>
<p><strong>注意：</strong> </p>
<p> 尽管动态设置大页面的数量在理论上是可行的，但实践中并非如此。减少大页面的数量决不会有问题，但是增加大页面的数量就会产生问题。原因是，为了创建一个大页，Linux需要在内存中找到足够大的连续的区域。如果找不到，就不能创建大页面。 </p>
<p> 刚启动系统时，内存的碎片还不是很多，所以要找到足够大的连续的区域并不是问题。但机器运行时间一长，内存会产生更多的碎片。所以，如果要确保能够分配足够大的页面，就必须在启动刚完成时通过启动脚本或手动设置它们。</p>
<hr /><small>  Copyright &copy; 2008 This feed is for personal, non-commercial use only<br />
<a href=www.hashei.com >聚沙成塔-小哈的记事薄</a> by hashei 
如果喜欢，欢迎订阅<a href=feed.hashei.com >feed.hashei.com</a><br />
Digital Fingerprint:
 10f920a9f2bae51c3c73c4f5fb50a949</small>]]></content:encoded>
			<wfw:commentRss>http://www.hashei.me/2009/09/weblogic_profiling_and_performance_tuning.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JDBC引发的服务器hang解决思路</title>
		<link>http://www.hashei.me/2009/08/jdbc_causes_server_hang.html?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=jdbc_causes_server_hang</link>
		<comments>http://www.hashei.me/2009/08/jdbc_causes_server_hang.html#comments</comments>
		<pubDate>Sun, 16 Aug 2009 03:58:36 +0000</pubDate>
		<dc:creator>hashei</dc:creator>
				<category><![CDATA[性能优化]]></category>
		<category><![CDATA[排错]]></category>
		<category><![CDATA[hang]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[weblogic]]></category>

		<guid isPermaLink="false">http://www.hashei.me/2009/08/jdbc_causes_server_hang.html</guid>
		<description><![CDATA[这篇也是转自BEA的官方文档，源地址在BEA被Oracle收购后就转到Oracle官网了，所以留为备份。虽然由BEA撰写，但是思路对所有中间件产品和应用开发都有用。]]></description>
			<content:encoded><![CDATA[<p>这篇也是转自BEA的官方文档，源地址在BEA被Oracle收购后就转到Oracle官网了，所以留为备份。</p>
<h4>JDBC Causes Server Hang</h4>
<p> <br />
<table style="width: 600px; text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top"><font color="#009900"><b><u>Problem Description</u></b></font><br />A JDBC connection which is used by an application or by WebLogic Server itself will block one WebLogic Server execute thread for the complete duration of the calls that are made via this connection. The JVM will ensure that the CPU is given to runnable threads by its thread scheduling mechanism, while the thread that blocks on a SQL query needs to wait. However, the thread occupied by the JDBC call will be reserved and used for the application until the call returns from the SQL query.</p>
<p>Even a transaction timeout will not kill or timeout any action that is done by the resources that are enlisted in this transaction. The actions will run as long as they take, without interruption. A transaction timeout will set a flag on the transaction that will mark it as rollback only, so that any subsequent request to commit this transaction will fail with a <font size="-1">TimedOutException</font> or <font size="-1">RollbackException</font>. However, as mentioned above, the long running JDBC calls can lead to blocked WebLogic Server execute threads, which can finally lead to a hanging instance, if all threads are blocked and no execute thread remains available for handling incoming requests.</p>
<p>More recent WebLogic Server versions have a health check functionality that regularly checks if a thread does not react for a certain period of time (the default is 600 seconds). If this happens, an error message is printed to your log file similar to following:</td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px" cellspacing="2" cellpadding="2" border="1">
<tbody>
<tr>
<td style="vertical-align: top; background-color: rgb(204,204,204)"><font size="-1">####&lt;Nov 6, 2004 1:42:30 PM EST&gt; &lt;Warning&gt; &lt;WebLogicServer&gt; &lt;mydomain&gt; &lt;myserver&gt; &lt;CoreHealthMonitor&gt;<br /> &lt;kernel identity&gt; &lt;&gt; <br />&lt;000337&gt; &lt;ExecuteThread: &#8216;64&#8242; for queue: &#8216;default&#8217; has been busy for &#8220;740&#8243; seconds working on the request &#8220;Scheduled Trigger&#8221;, <br />which is more than the configured time (StuckThreadMaxTime) of &#8220;600&#8243; seconds.&gt;</font><font size="-1"><br /></font></td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px; text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top"><a name="1"></a>This does not interrupt the thread, as this is just a notification for the administrator. The only way a stuck thread becomes unstuck again is when the request it is handling finishes. In this case, you will find a message similar to following in your WebLogic Server&#8217;s log file:</td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px" cellspacing="2" cellpadding="2" border="1">
<tbody>
<tr>
<td style="vertical-align: top; background-color: rgb(204,204,204)"><font size="-1">####&lt;Nov 7, 2004 4:17:34 PM EST&gt; &lt;Info&gt; &lt;WebLogicServer&gt;&lt;mydomain&gt; &lt;myserver&gt; &lt;ExecuteThread: &#8216;66&#8242;<br /> for queue: &#8216;default&#8217;&gt;<br />&lt;kernel identity&gt; &lt;&gt; &lt;000339&gt; &lt;ExecuteThread: &#8216;66&#8242; for queue: &#8216;default&#8217; has become &#8220;unstuck&#8221;.&gt;</font><font size="-1"><br /></font></td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px; text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top">The time interval for the health check functionality is configurable. Please check <font size="-1">StuckThreadMaxTime</font> property in the <span style="font-style: italic">&lt;Server&gt;</span> tag of your <font size="-1">config.xml</font> file: <a href="http://e-docs.bea.com/wls/docs81/config_xml/Server.html#StuckThreadMaxTime">http://e-docs.bea.com/wls/docs81/config_xml/Server.html#StuckThreadMaxTime</a> or the &#8220;Detecting stuck threads&#8221; section in the WebLogic Server administration console help: <a href="http://e-docs.bea.com/wls/docs81/perform/WLSTuning.html#stuckthread">http://e-docs.bea.com/wls/docs81/perform/WLSTuning.html#stuckthread</a>.</p>
<p><font size="-1"><a href="#TOP">Top of Page</a></font></p>
<p><font color="#009900"><u><b><a name="Problem_Troubleshooting"></a>Problem Troubleshooting</b></u></font><br />Different programming techniques or JDBC connection pool configurations can lead to deadlocks or long running JDBC calls that lead to hanging WebLogic Server instances. General information about how to troubleshoot and analyze a hanging WebLogic Server instance is provided in <a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/Generic_Server_Hang_Pattern.html">Generic Server Hang Pattern</a>.</p>
<p>This pattern addresses JDBC calls causing a server hang and other well known JDBC-related causes for common problems leading to hanging WebLogic Server instance.&nbsp; Other Support Patterns referenced in this pattern are at the <a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/wls_support_patterns.jsp">WebLogic Server Support Patterns Site</a>.</p>
<p><span style="font-weight: bold; text-decoration: underline">Quick Links</span><font color="#009900"><u><b><br /></b></u></font>
<ul>
<li><a href="#Why_does_the_problem_occur"><span style="color: rgb(0,0,238); text-decoration: underline">Why does the problem occur?</span></a>
<li><a href="#Analysis_of_a_hanging_WebLogic_Server"><span style="color: rgb(0,0,238); text-decoration: underline">Analysis of a hanging WebLogic Server instance</span></a>
<li><a href="#Tips_and_Tricks_to_optimize_your_JDBC"><span style="color: rgb(0,0,238); text-decoration: underline">Tips and Tricks to optimize your JDBC code and JDBC connection pool configuration</span></a> </li>
</ul>
<p><a name="Why_does_the_problem_occur"></a><span style="font-weight: bold; text-decoration: underline">Why does the problem occur?</span><br />The following are some different possible reasons that can cause JDBC calls to lead to a hanging WebLogic Server instance:<br /> 
<ul>
<li>Use of <a href="#DriverManager.getConnection">DriverManager.getConnection()</a> in your JDBC code.
<li><a href="#Long_Running_SQL_Queries">SQL Queries</a> issued to the database take unexpectedly long time to return.
<li><a href="#Hanging_Database">Database</a> for which the JDBC connection pool is configured hangs and does not return from calls in a timely manner.
<li>A slow or overloaded <a href="#Slow_Network">network</a> causes database calls to slow down or hang.<br /> 
<li>A <a href="#Deadlock">deadlock</a> causes all execute threads to hang and wait forever.
<li><a href="#RefreshMinutes">RefreshMinutes or TestFrequencySeconds</a> property in the JDBC connection pool causes hang periods in WebLogic Server.
<li><a href="#Pool_Shrinking">JDBC connection pool shrinking</a> and re-creation of database connections causes long response times. </li>
</ul>
<p><font size="-1"><a href="#TOP">Top of Page</a></font></p>
<p><a name="DriverManager.getConnection"></a><span style="font-weight: bold">Synchronized DriverManager.getConnection()</span><br />Older JDBC application code sometimes uses <font size="-1">DriverManager.getConnection()</font> calls to retrieve a database connection using a certain driver. This technique is not recommended as it can cause deadlocks or at least relatively low performance for your connection requests. The reason behind this is, that all DriverManager calls are class-synchronized, meaning that one DriverManager call in one thread will block all other DriverManager calls in any other thread inside one WebLogic Server instance.</p>
<p>In addition to that, the constructor for a <font size="-1">SQLException</font> makes a DriverManager call, and most drivers have <font size="-1">DriverManager.println() </font>calls for logging, so any of these can block all other threads that issue a DriverManager call.</p>
<p><font size="-1">DriverManager.getConnection()</font> can take a relatively long time until it returns with the physical connection created to the database. Even if no deadlock occurs, all other calls need to wait until that one thread gets its connection. This is not a best practice in a multi-threaded system like WebLogic Server.</td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px; text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top">This information is taken from <a href="http://forums.bea.com/bea//thread.jspa?forumID=2022&amp;threadID=200063365&amp;messageID=202311284&amp;start=-1#202311284">http://forums.bea.com/bea//thread.jspa?forumID=2022&amp;threadID=200063365&amp;messageID=202311284&amp;start=-1#202311284</a>. </td>
</tr>
</tbody>
</table>
<table style="width: 600px; height: 252px; text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top">Also our documentation clearly states that <font size="-1">DriverManager.getConnection()</font> should not be used: <a href="http://e-docs.bea.com/wls/docs81/faq/jdbc.html#501044">http://e-docs.bea.com/wls/docs81/faq/jdbc.html#501044</a>.</p>
<p><a name="2"></a>If you prefer to use JDBC connections in your JDBC code, you should use a WebLogic Server JDBC connection pool, define a DataSource for it, and get the connection from the DataSource. This will give you all advantages from a pool (resource sharing, connection reuse, connection refresh if a database was down, etc). It also will help you avoid the deadlocks that may happen with DriverManager calls. See detailed information on how to use JDBC connection pools, DataSources, and other JDBC objects in WebLogic Server at: <a href="http://e-docs.bea.com/wls/docs81/jdbc/intro.html#1036718">http://e-docs.bea.com/wls/docs81/jdbc/intro.html#1036718</a> and <a href="http://e-docs.bea.com/wls/docs81/jdbc/programming.html#1054307">http://e-docs.bea.com/wls/docs81/jdbc/programming.html#1054307</a>.</p>
<p>A typical thread blocked in a <font size="-1">DriverManager.getConnection()</font> call looks like:</td>
</tr>
</tbody>
</table>
<table style="width: 600px" cellspacing="2" cellpadding="2" width="611" border="1">
<tbody>
<tr>
<td style="vertical-align: top; background-color: rgb(204,204,204)" width="605"><font size="-1">&#8220;ExecuteThread-39&#8243; daemon prio=5 tid=0&#215;401660 nid=0&#215;33 waiting for monitor entry [0xd247f000..0xd247fc68]<br />&nbsp; at java.sql.DriverManager.getConnection(DriverManager.java:188)<br />&nbsp; at com.bla.updateDataInDatabase(MyClass.java:296)<br />&nbsp; at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)<br />&nbsp; at weblogic.servlet.internal.ServletStubImpl.invokeServlet<br />(ServletStubImpl.java:120)<br />&nbsp; at weblogic.servlet.internal.ServletContextImpl.invokeServlet<br />(ServletContextImpl.java:945)<br />&nbsp; at weblogic.servlet.internal.ServletContextImpl.invokeServlet<br />(ServletContextImpl.java:909)<br />&nbsp; at weblogic.servlet.internal.ServletContextManager.invokeServlet<br />(ServletContextManager.java:269)<br />&nbsp; at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:392)<br />&nbsp; at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:274)<br />&nbsp; at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:130)</font></p>
</td>
</tr>
</tbody>
</table>
<p><font size="-1"><a href="#TOP">Top of Page</a></font></p>
<table style="width: 600px; text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top"><a name="Long_Running_SQL_Queries"></a><span style="font-weight: bold">Long Running SQL Queries </span><br />Long running SQL queries block execute threads for their duration and until they return their result to the calling application. This means that a WebLogic Server instance needs to be configured to be able to handle enough calls simultaneously as they are requested by the application load. Limiting factors here are the number of execute threads and the number of connections in the JDBC connection pools. A general rule of thumb is to set the number of connections in the pool equally to the number of execute threads to enable optimal resource utilization. If JTS is used, some more connections in the pools should be available because connections may be reserved for transactions that are actually not active.</p>
<p>A thread hanging in a long running SQL call will show a very similar stack in a thread dump as the one for a <a href="#Hanging_Database">hanging database</a>. Please compare the next section for details.</p>
<p><a name="Hanging_Database"></a><span style="font-weight: bold">Hanging Database</span> <br />Good database performance is key for the performance of an application that relies on this database. Consequently, a hanging database can block many or all available execute threads in a WebLogic Server instance and finally lead to a hanging server. To diagnose this, you should take 5 to 10 thread dumps from your hanging WebLogic Server instance and check your execute threads (in the default queue or your application thread queue) to see if they are currently in SQL calls and waiting for a result from the database. A typical stack trace for a thread that currently issues a sql query could look similar to following example:</td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px" cellspacing="2" cellpadding="2" border="1">
<tbody>
<tr>
<td style="vertical-align: top; background-color: rgb(204,204,204)" width="719"><font size="-1">&#8220;ExecuteThread: &#8216;4&#8242; for queue: &#8216;weblogic.kernel.Default&#8217;&#8221; daemon prio=5 tid=0&#215;8e93c8 nid=0&#215;19 runnable [e137f000..e13819bc]<br />&nbsp; at java.net.SocketInputStream.socketRead0(Native Method)<br />&nbsp; at java.net.SocketInputStream.read(SocketInputStream.java:129)<br />&nbsp; at oracle.net.ns.Packet.receive(Unknown Source)<br />&nbsp; at oracle.net.ns.DataPacket.receive(Unknown Source)<br />&nbsp; at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)<br />&nbsp; at oracle.net.ns.NetInputStream.read(Unknown Source)<br />&nbsp; at oracle.net.ns.NetInputStream.read(Unknown Source)<br />&nbsp; at oracle.net.ns.NetInputStream.read(Unknown Source)<br />&nbsp; at oracle.jdbc.ttc7.MAREngine.unmarshalUB1(MAREngine.java:931)<br />&nbsp; at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:893)<br />&nbsp; at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:375)<br />&nbsp; at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)<br />&nbsp; at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:1250)<br />&nbsp; &#8211; locked &lt;e8c68f00&gt; (a oracle.jdbc.ttc7.TTC7Protocol)<br />&nbsp; at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2529)<br />&nbsp; at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout<br />(OracleStatement.java:2857)<br />&nbsp; at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)<br />&nbsp; &#8211; locked &lt;e5cc44d0&gt; (a oracle.jdbc.driver.OraclePreparedStatement)<br />&nbsp; &#8211; locked &lt;e8c544c8&gt; (a oracle.jdbc.driver.OracleConnection)<br />&nbsp; at oracle.jdbc.driver.OraclePreparedStatement.executeQuery<br />(OraclePreparedStatement.java:536)<br />&nbsp; &#8211; locked &lt;e5cc44d0&gt; (a oracle.jdbc.driver.OraclePreparedStatement)<br />&nbsp; &#8211; locked &lt;e8c544c8&gt; (a oracle.jdbc.driver.OracleConnection)<br />&nbsp; at weblogic.jdbc.wrapper.PreparedStatement.executeQuery(PreparedStatement.java:80)<br />&nbsp; at myPackage.query.getAnalysis(MyClass.java:94)<br />&nbsp; at jsp_servlet._jsp._jspService(__jspService.java:242)<br />&nbsp; at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)<br />&nbsp; at weblogic.servlet.internal.ServletStubImpl$<br />ServletInvocationAction.run(ServletStubImpl.java:971)<br />&nbsp; at weblogic.servlet.internal.ServletStubImpl.invokeServlet<br />(ServletStubImpl.java:402)<br />&nbsp; at weblogic.servlet.internal.ServletStubImpl.invokeServlet<br />(ServletStubImpl.java:305)<br />&nbsp; at weblogic.servlet.internal.RequestDispatcherImpl.include<br />(RequestDispatcherImpl.java:607)<br />&nbsp; at weblogic.servlet.internal.RequestDispatcherImpl.include<br />(RequestDispatcherImpl.java:400)<br />&nbsp; at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:154)<br />&nbsp; at jsp_servlet._jsp.__mf1924jq._jspService(__mf1924jq.java:563)<br />&nbsp; at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)<br />&nbsp; at weblogic.servlet.internal.ServletStubImpl$<br />ServletInvocationAction.run(ServletStubImpl.java:971)<br />&nbsp; at weblogic.servlet.internal.ServletStubImpl.invokeServlet<br />(ServletStubImpl.java:402)<br />&nbsp; at weblogic.servlet.internal.ServletStubImpl.invokeServlet<br />(ServletStubImpl.java:305)<br />&nbsp; at weblogic.servlet.internal.WebAppServletContext$<br />ServletInvocationAction.run(WebAppServletContext.java:6350)<br />&nbsp; at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)<br />&nbsp; at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)<br />&nbsp; at weblogic.servlet.internal.WebAppServletContext.invokeServlet<br />(WebAppServletContext.java:3635)<br />&nbsp; at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)<br />&nbsp; at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)<br />&nbsp; at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)</font></td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px; text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top">The thread will be in running state. You should compare the threads in your different thread dumps in order to see if they receive the return from the SQL call in a timely manner or if they hang in this same call for a longer period of time. If the thread dumps seem to imply long response times from SQL calls, the corresponding database logs should be checked to see if problems in the database cause this slow performance or hang situation.</p>
<p><font size="-1"><a href="#TOP">Top of Page</a></font></p>
<p><a name="Slow_Network"></a><span style="font-weight: bold">Slow Network</span> <br />Communication between WebLogic Server and the database relies on a well-performing and reliable network in order to serve the requests in a timely manner. Slow network performance can therefore lead to hanging or blocking execute threads waiting for results of SQL queries. The related stack traces will look similar to example above in <a href="#Hanging_Database">Hanging Database</a> section. It is not possible to find the root cause of the hanging or slow SQL queries by solely analyzing the WebLogic Server thread dumps. These give the first hint that something is wrong with the performance of the SQL calls. The next step is to check if there is a database or network problem that causes poorly performing SQL calls.</p>
<p><a name="Deadlock"></a><span style="font-weight: bold">Deadlock</span> <br />Both an application level deadlock as well as a deadlock on the database level can lead to hanging threads. You should check your thread dumps to see if there is an application level deadlock. Information on how to do this is provided in <a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/ServerHang_Application_Deadlock_Pattern.html">Server Hang &#8211; Application Deadlock Pattern</a>. A database deadlock can be detected either in the database log or by the SQL Exception that can be found in the WebLogic Server log file. An example for a related SQL Exception is:</td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px" cellspacing="2" cellpadding="2" border="1">
<tbody>
<tr>
<td style="vertical-align: top; background-color: rgb(204,204,204)"><font size="-1">java.sql.SQLException: ORA-00060: deadlock detected while waiting for resource<br />&nbsp; at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:170)<br />&nbsp; at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:1614)<br />&nbsp; at oracle.jdbc.oci8.OCIDBAccess.executeFetch(OCIDBAccess.java:1225)<br />&nbsp; at oracle.jdbc.oci8.OCIDBAccess.parseExecuteFetch(OCIDBAccess.java:1338)<br />&nbsp; at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1722)<br />&nbsp; at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1647)<br />&nbsp; at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2167)<br />&nbsp; at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate<br />(OraclePreparedStatement.java:404)</font><font size="-1"><br /></font></td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px; text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top">As it generally can take some time until a database detects a deadlock and resolves it by rolling back one or more transactions that cause the deadlock, one or more execute threads will be blocked until the rollback has finished.</p>
<p><a name="RefreshMinutes"></a><span style="font-weight: bold">RefreshMinutes or TestFrequencySeconds</span><br />If you see recurring periods of low database performance, slow SQL calls, or connection peaks, the setting of the <font size="-1">RefreshMinutes</font> or <font size="-1">TestFrequencySeconds</font><span style="font-style: italic"> </span>configuration property in your JDBC connection pools could be the reason. This is described in detail in <a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/Investigating_JDBC_Problems_Pattern.html">Investigating JDBC Problems Pattern</a>. Unless you do not have a firewall between your WebLogic Server instance and your database, you should disable this functionality.</p>
<p><a name="Pool_Shrinking"></a><span style="font-weight: bold">Pool Shrinking</span> <br />Physical connections to a database are resources that should be opened once and kept open as long as possible, as a new connection request is a considerable resource overhead for the database, the operating system kernel, and the WebLogic Server. Consequently, pool shrinking should be disabled on production systems in order to keep this overhead at a minimum. If pool shrinking is enabled, idle pool connections will be closed and reopened once connection requests to the pool cannot be satisfied.</p>
<p>As these activities can take some time, the related application requests may take an unexpectedly long time which can lead users to assume that the system hangs. Information on how to optimize JDBC connection pool configurations is provided in <a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/Investigating_JDBC_Problems_Pattern.html">Investigating JDBC Problems Pattern</a>.</p>
<p><font size="-1"><a href="#TOP">Top of Page</a></font></p>
<p><span style="font-weight: bold; color: rgb(0,0,0); text-decoration: underline"><a name="Analysis_of_a_hanging_WebLogic_Server"></a>Analysis of a hanging WebLogic Server instance</span><br />General information on how to analyze a hanging WebLogic Server instance is provided in <a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/Generic_Server_Hang_Pattern.html">Generic Server Hang Pattern</a>. </p>
<p>Most times it will be helpful to start with taking thread dumps from the hanging system in order to find out what is going on, e.g., what the different threads are doing and why they hang. Generally, thread dumps can be taken on production systems, however caution is necessary for very old versions of the JVM (&lt;1.3.1_09), as they may crash during thread dumps. Also if the WebLogic Server instance has a huge number of threads, it will mean that the thread dump will take awhile to complete, while the rest of the threads are blocked.</p>
<p>Please take more than one thread dump (5 to 10) with a delay of some seconds in between. This gives you the possibility to check the progress of the different threads. Also it will show if the system actually hangs (no progress at all) or if the throughput is extremely slow, which can seem to be a hanging system.</p>
<p>Information on how to take thread dumps is provided in &#8220;Generic Server Hang&#8221; support pattern or in our documentation: <a href="http://e-docs.bea.com/wls/docs81/cluster/trouble.html">http://e-docs.bea.com/wls/docs81/cluster/trouble.html</a>.</p>
<p>Also please check if the complete WebLogic Server instance hangs or if it is the application that hangs. &#8220;Generic Server Hang&#8221; support pattern also includes this information.</p>
<p><a name="3"></a>Analyzing the thread dumps can show if one of the reasons mentioned in the previous section <a href="#Why_does_the_problem_occur">Why does the problem occur?</a> actually is responsible for your hanging instance. If for example all your threads are in a DriverManager method like <font size="-1">getConnection()</font> then you have identified the root cause and need to change your application to use a DataSource or <font size="-1">Driver.connect()</font> instead of <font size="-1">DriverManager.getConnection()</font>.</p>
<p>A very useful tool, Samurai, can be used to analyze thread dumps and to monitor the progress of threads between different thread dumps. This can be downloaded from dev2dev at:&nbsp; <a href="http://dev2dev.bea.com/resourcelibrary/utilitiestools/adminmgmt.jsp">http://dev2dev.bea.com/resourcelibrary/utilitiestools/adminmgmt.jsp</a>.</p>
<p>A whitepaper on analyzing thread dumps on dev2dev: <a href="http://dev2dev.bea.com/products/wlplatform81/articles/thread_dumps.jsp">http://dev2dev.bea.com/products/wlplatform81/articles/thread_dumps.jsp</a> will also be helpful in going deeper into the thread dumps to find out more about the server hang. </p>
<p><font size="-1"><a href="#TOP">Top of Page</a></font></p>
<p><span style="font-weight: bold; color: rgb(0,0,0); text-decoration: underline"><a name="Tips_and_Tricks_to_optimize_your_JDBC"></a>Tips and Tricks to optimize your JDBC code and JDBC connection pool configuration</span><br />There are some best practices both in the development of JDBC code and also in the configuration practice of JDBC connection pools that can help to avoid common problems and optimize resource usage so that hanging server instances should not happen.</p>
<p><span style="font-weight: bold"><a name="JDBC_Programming"></a>JDBC Programming </span><br />In order to optimize resource usage in WebLogic Server and conserve database resources, you should use JDBC connection pools for your application&#8217;s JDBC calls. Connections created and destroyed in your application code generate an unnecessary overhead which should be avoided. For generic documentation on JDBC programming, see: <a href="http://e-docs.bea.com/wls/docs81/jdbc/rmidriver.html#1028977">http://e-docs.bea.com/wls/docs81/jdbc/rmidriver.html#1028977</a>. Also details on JDBC performance tuning are at: <a href="http://e-docs.bea.com/wls/docs81/jdbc/performance.html#1027791">http://e-docs.bea.com/wls/docs81/jdbc/performance.html#1027791</a>.</p>
<p>You can view comprehensive information on JDBC that will help to optimize your JDBC code and the utilization of your JDBC resources on dev2dev Java Database Connectivity page at: <a href="http://dev2dev.bea.com/technologies/jdbc/index.jsp">http://dev2dev.bea.com/technologies/jdbc/index.jsp</a>.</p>
<p><span style="font-weight: bold"><a name="JDBC_Connection_Pool_Configuration"></a>JDBC Connection Pool Configuration</span><br />The <a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/Investigating_JDBC_Problems_Pattern.html">Investigating JDBC Problems Pattern</a> has recommendations on how to configure a connection pool for production environments. In order to avoid hangs or bad performance, these configuration tips should be considered. </td>
</tr>
</tbody>
</table>
<p><font size="-1"><a href="#TOP">Top of Page</a></font></p>
<table style="width: 600px; text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top"><font color="#009900"><u><b><a name="Known_Issues"></a>Known Issues</b></u></font><br /><span style="color: rgb(0,0,0)">You can periodically review the Release Notes for your version of WLS for more information on Known Issues or Resolved Issues in Service Packs and browse for JDBC server hang-related issues.&nbsp; </span><span style="color: rgb(0,0,0)">For your convenience, see the following: <br /></span>
<ul>
<li><span style="color: rgb(0,0,0)"><a href="http://edocs/wls/docs81/notes/index.html">WLS 8.1 Release Notes</a></span>
<li><span style="color: rgb(0,0,0)"><a href="http://edocs/wls/docs70/notes/index.html">WLS 7.0 Release Notes</a></span>
<li><span style="color: rgb(0,0,0)"><a href="http://edocs/wls/docs61/notes/index.html">WLS 6.1 Release Notes</a></span> </li>
</ul>
<p><span style="color: rgb(0,0,0)">Please note that changes have been made in <a href="http://e-docs.bea.com/wls/docs81/notes/resolved_sp03.html#1817208">WLS 8.1 SP3</a> to resolve CR134921, where for certain JDBC connections, the call to roll back a transaction was not being handled immediately because the driver had to wait for any currently-executing statement to return.&nbsp; <br /><span style="color: rgb(0,0,0)"><br />Searching will also return Release Notes, as well as other Support Solutions and CR-related information as noted at <a href="#Need_Further_Help?">Need Further Help?</a>.&nbsp; Contract customers who are logged in at </span><span style="font-size: 12pt; font-family: 'Times New Roman'"><a href="http://support.bea.com/">http://support.bea.com/</a> will also see a Browse portlet for both Solutions and Bug Central where latest available CRs can be browsed by Product version.</span><br /></span></td>
</tr>
</tbody>
</table>
<p> <br />
<table style="width: 600px; color: rgb(0,0,0); text-align: left" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top"><span style="text-decoration: underline"><span style="font-weight: bold"><a name="Need_Further_Help?"></a>Need Further Help?</span></span><br /><span style="font-size: 12pt; font-family: 'Times New Roman'">If you have followed the pattern, but still require additional help, you can:<br /></span>
<ol>
<li><span style="font-size: 12pt; font-family: 'Times New Roman'">Query AskBEA at </span><span style="font-size: 12pt; font-family: 'Times New Roman'"><a href="http://support.bea.com/">http://support.bea.com/</a></span><span style="font-size: 12pt; font-family: 'Times New Roman'"> </span><span style="font-size: 12pt; font-family: 'Times New Roman'">using </span><span style="font-size: 12pt; font-family: 'Times New Roman'">&#8220;jdbc server hang&#8221;, as an example, to discover other published solutions.&nbsp; </span><span style="font-size: 12pt; color: rgb(0,0,0); font-family: 'Times New Roman'">Contract Support Customers: Ensure you are logged to access available CR-related information.</span>
<li><span style="font-size: 12pt; font-family: 'Times New Roman'">Ask a more detailed question on one of BEA&#8217;s newsgroups at </span><a href="http://newsgroups.bea.com/">http://forums.bea.com<br /></a></li>
</ol>
<p>If this does not resolve your issue and you have a valid Support Contract, you can open a Support Case by logging in at: <span style="font-size: 12pt; font-family: 'Times New Roman'"><a href="http://support.bea.com/">http://support.bea.com/</a></span> .</td>
</tr>
</tbody>
</table>
<p> <br />
<table width="600" border="2">
<tbody>
<tr>
<td>
<p><strong>FEEDBACK</strong></p>
<p><font color="#000000">Please provide us input on whether or not this Support Diagnostic Pattern <strong>&#8220;JDBC Causes Server Hang&#8221;</strong> helped, any clarifications you needed, and any requests for new topics to <a href="mailto:support.ke@bea.com?subject=Patterns%20Feedback:%20JDBC%20Causes%20Server%20Hang&amp;body=">Support Diagnostic Patterns</a>. <br /></font></p>
</td>
</tr>
</tbody>
</table>
<p> <br />
<table width="600" border="2"><!--DWLayoutTable--><br />
<tbody>
<tr>
<td height="78">
<p><strong>DISCLAIMER NOTICE:</strong></p>
<p>BEA Systems, Inc. provides the technical tips and patches on this Website for your use under the terms of BEA&#8217;s maintenance and support agreement with you. While you may use this information and code in connection with software you have licensed from BEA, BEA makes no warranty of any kind, express or implied, regarding the technical tips and patches.</p>
<p>Any trademarks referenced in this document are the property of their respective owners. Consult your product manuals for complete trademark information.</p>
</td>
</tr>
</tbody>
</table>
<hr /><small>  Copyright &copy; 2008 This feed is for personal, non-commercial use only<br />
<a href=www.hashei.com >聚沙成塔-小哈的记事薄</a> by hashei 
如果喜欢，欢迎订阅<a href=feed.hashei.com >feed.hashei.com</a><br />
Digital Fingerprint:
 10f920a9f2bae51c3c73c4f5fb50a949</small>]]></content:encoded>
			<wfw:commentRss>http://www.hashei.me/2009/08/jdbc_causes_server_hang.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>应用服务器发生hang的诊断方法</title>
		<link>http://www.hashei.me/2009/08/java_generic_server_hang.html?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=java_generic_server_hang</link>
		<comments>http://www.hashei.me/2009/08/java_generic_server_hang.html#comments</comments>
		<pubDate>Sat, 15 Aug 2009 15:04:26 +0000</pubDate>
		<dc:creator>hashei</dc:creator>
				<category><![CDATA[性能优化]]></category>
		<category><![CDATA[排错]]></category>
		<category><![CDATA[hang]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[thread dump]]></category>
		<category><![CDATA[weblogic]]></category>

		<guid isPermaLink="false">http://www.hashei.me/2009/08/java_generic_server_hang.html</guid>
		<description><![CDATA[写在前面
其实这是BEA官网上的一篇文档，是在weblogic8.1的时候推出的。在BEA被Oracle收购后，所有的support文章也就被重定向到Oracle的官网首页= =，而且google的快照也没有了。这篇来自无意间google到的一个外国论坛，虽然是写在8.1时，但是解决问题的方法和思路现在依旧有效。本想理解之后结合案例来写一篇，但是最近一直没有遇到相关的问题，而且觉得那样也许会破坏文章的完整性，所以放出原文，既在网上留个副本，也能让大家各取所需，见仁见智。
从内容看，你会发现除了这篇，还有EJB_RMI Server Hang、Application Dead Lock、JDBC Causes Server Hang，但是那个论坛里还能找到的仅有JDBC Causes Server Hang一篇。所以如果你接触weblogic比较早，保存过另两篇文章，或者在网上看到了，那请留言说明，万分感谢。
Generic Hang



Problem Description
A server hang is suspected when:

The server does not respond to new requests.
Requests time out.
Requests take longer and longer to process (may be on the way to a hang).
A server crash is not usually a symptom of a hung server but may [...]]]></description>
			<content:encoded><![CDATA[<h4>写在前面</h4>
<p style="text-indent: 24pt">其实这是BEA官网上的一篇文档，是在weblogic8.1的时候推出的。在BEA被Oracle收购后，所有的support文章也就被重定向到Oracle的官网首页= =，而且google的快照也没有了。这篇来自无意间google到的一个外国论坛，虽然是写在8.1时，但是解决问题的方法和思路现在依旧有效。本想理解之后结合案例来写一篇，但是最近一直没有遇到相关的问题，而且觉得那样也许会破坏文章的完整性，所以放出原文，既在网上留个副本，也能让大家各取所需，见仁见智。</p>
<p style="text-indent: 24pt">从内容看，你会发现除了这篇，还有EJB_RMI Server Hang、Application Dead Lock、JDBC Causes Server Hang，但是那个论坛里还能找到的仅有JDBC Causes Server Hang一篇。所以如果你接触weblogic比较早，保存过另两篇文章，或者在网上看到了，那请留言说明，万分感谢。</p>
<h4><span style="font-size: medium;"><span style="line-height: normal; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Generic Hang</span></span></h4>
<table style="width: 600px; text-align: left;" border="0" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top"><strong><span style="text-decoration: underline;">Problem Description</span></strong><br />
A server hang is suspected when:</p>
<ul>
<li>The server does not respond to new requests.</li>
<li>Requests time out.</li>
<li>Requests take longer and longer to process (may be on the way to a hang).</li>
<li>A server crash is not usually a symptom of a hung server but may follow.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<table style="width: 600px; text-align: left;" border="0" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top"><span style="text-decoration: underline;"><strong>Problem Troubleshooting</strong><strong><br />
</strong></span>Please note that not all of the following items would need to be done. Some issues can be solved by only following a few of the items.<strong><span style="text-decoration: underline;">Quick Links:</span></strong></p>
<ul>
<li><span style="text-decoration: underline;"><a href="#Why_does_the_problem_occur?">Why does the problem occur?</a></span></li>
<li><span style="text-decoration: underline;"><a href="#Potential_Causes_of_Server_Hang">Potential Causes of Server Hang</a></span></li>
<li><span style="text-decoration: underline;"><a href="#Basic_Steps">Basic Steps</a></span></li>
<li><span style="text-decoration: underline;"><a href="#Known_WebLogic_Server_Issues">Known WebLogic Server Issues</a></span></li>
<li><span style="text-decoration: underline;"><a href="#Collecting_Thread_Dumps">Collecting Thread Dumps</a></span></li>
<li><span style="text-decoration: underline;"><a href="#Analysis_of_Thread_Dump">Analysis of a Thread Dump</a></span></li>
</ul>
<p><span style="text-decoration: underline;"><strong><a name="Why_does_the_problem_occur?"></a></strong><span style="text-decoration: underline;"><strong>Why does the problem occur?</strong></span><strong> </strong></span><br />
A server can hang for a variety of reasons (refer to <a href="#Potential_Causes_of_Server_Hang">Potential Causes of Server Hang</a>). Generally, a server hangs because of a lack of some resource. Lack of a resource prevents the server from servicing requests. For example, because of a problem (deadlock) or volume of requests there may be no execute threads available to do any work; all are busy or busy with previous requests.</p>
<p><span><a href="#TOP">Top of Page</a></span></p>
<p><strong><span style="text-decoration: underline;"><a name="Potential_Causes_of_Server_Hang"></a></span></strong></td>
</tr>
</tbody>
</table>
<table border="1" width="600">
<tbody>
<tr>
<td width="45%">
<div><strong>Topic</strong></div>
</td>
<td width="25%">
<div><strong>Pattern Name</strong></div>
</td>
<td width="30%">
<div><strong>Link</strong></div>
</td>
</tr>
<tr>
<td valign="top">RMI, RJVM responses – all threads tied up waiting for RJVM, RMI responses.</td>
<td>EJB_RMI Server Hang</td>
<td>
<div><a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/EJB_RMI_Server_Hang_Pattern.html">EJB_RMI Server Hang</a></div>
</td>
</tr>
<tr>
<td valign="top">Application Deadlock – thread locks resource1 then waits for lock for resource2. Another thread locks resource2 and then waits for lock for resource1.</td>
<td>Application Deadlock Causes Server Hang</td>
<td style="color: #ff0000">
<div><a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/ServerHang_Application_Deadlock_Pattern.html">Application Dead Lock</a></div>
</td>
</tr>
<tr>
<td valign="top">Threads are all used up, none available for new work.</td>
<td>Thread Usage Server Hang</td>
<td>TBD</td>
</tr>
<tr>
<td valign="top">Garbage Collection taking too much time.</td>
<td>Garbage Collection Server Hang</td>
<td>TBD</td>
</tr>
<tr>
<td valign="top">JSP improper settings for servlet times, e.g. PageCheckSeconds.</td>
<td>JSP cause Server Hang</td>
<td>TBD</td>
</tr>
<tr>
<td valign="top">Long Running JDBC calls or JDBC deadlocks lead to a hang.</td>
<td><span style="color: #000000">JDBC Causes Server Hang</span></td>
<td style="text-align: center"><a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/JDBC_Causes_Server_Hang_Pattern.html">JDBC Causes Server Hang</a></td>
</tr>
<tr>
<td valign="top">JVM hang during (code optimization), looks like server hang.</td>
<td>Server Hang in Code Optimization</td>
<td>TBD</td>
</tr>
<tr>
<td valign="top">JSP compilation causes server hang under heavy load.</td>
<td>JSP Compilation Server Hang</td>
<td><a href="http://support.bea.com/application_content/product_portlets/support_patterns/wls/JDBC_Causes_Server_Hang_Pattern.html"></a>TBD</td>
</tr>
<tr>
<td valign="top">SUN JVM bugs, e.g. Light weight thread library.</td>
<td>Sun JVM Bugs that Cause Server Hangs</td>
<td>TBD</td>
</tr>
</tbody>
</table>
<table style="width: 600px; text-align: left;" border="0" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top"><span><a href="#TOP">Top of Page</a></span></p>
<p><a name="Basic_Steps"></a><br />
When a server is hanging, first ping the server using <span style="font-family: 'Courier New', Courier, mono;">java weblogic.Admin t3://server:port PING</span>. If the server can respond to the ping, it may be that the application is hanging and not the server itself.</p>
<p>Ensure that the server is actually hanging and not doing garbage collection. To verify, restart the server with <span style="font-family: 'Courier New', Courier, mono;">-verbosegc</span> turned on, and redirect <span style="font-family: 'Courier New', Courier, mono;">stdout</span> and <span style="font-family: 'Courier New', Courier, mono;">stderr</span> to one file. When the server stops responding, it can be determined if it’s doing garbage collection or it is really hanging.  If the garbage collection is taking too long (&gt;10 seconds), the server may miss the heartbeats that servers use to keep each other informed of the topoplogy of the cluster.</p>
<p>WebLogic Server uses the ‘default’ thread queue or a configured application specific thread queue<span style="color: #ff0000"> </span>to service client requests.<span style="color: #ff0000"> </span>Client requests will only be handled in the default queue if no application specific thread queue is defined.  Please see <a href="http://e-docs.bea.com/wls/docs81/perform/AppTuning.html#11052010">Tuning WebLogic Server Applications</a>, <a href="http://e-docs.bea.com/wls/docs81/perform/WLSTuning.html#1140013">Tuning the Default Execute Queue Threads</a>, and <a href="http://e-docs.bea.com/wls/docs81/perform/topten.html#1129089">Tuning WebLogic Server Performance Parameters</a> for more information on defining application specific thread queues. <a href="http://e-docs.bea.com/wls/docs81/perform/topten.html#1129089"><br />
</a></p>
<p>In release 8.1, a change was made to the thread architecture in WebLogic Server.  A specific kernel thread group for internal WebLogic tasks was created.  This was found to be necessary to avoid deadlocks that occurred in earlier releases when all threads in the &#8216;default&#8217; thread queue were used and none were thus available for WebLogic internal tasks.<span style="color: #ff0000"> </span></p>
<p>The threads in the &#8216;default&#8217; queue or the application specific thread queue (if one has been configured)<span style="color: #ff0000"> </span>are the threads that should be examined in the event of a server hang.<span style="color: #ff0000"> </span>Here’s an example of what one of these threads looks like in a thread dump. Execute Thread &#8216;14&#8242; from the &#8216;default&#8217; queue looks like in a thread dump when the thread is waiting for work. The latest method called by this thread is <span style="font-family: 'Courier New', Courier, mono;">Object.wait()</span>. This thread is in a state &#8220;waiting on monitor&#8221;.</td>
</tr>
</tbody>
</table>
<table style="width: 600px;" border="1" cellspacing="2" cellpadding="2" width="700">
<tbody>
<tr>
<td style="vertical-align: top; background-color: #cccccc" width="700"><span>&#8220;ExecuteThread: &#8216;14&#8242; for queue: &#8216;default&#8217;&#8221; daemon prio=5 tid=0&#215;8b0ab30 nid=0&#215;1f4 waiting on monitor [0x96af000..0x96afdc4]</span><br />
<span>at</span><br />
<span>java.lang.Object.wait(Native Method)</span><br />
<span>at</span><br />
<span>java.lang.Object.wait(Object.java:420)</span><br />
<span>at</span><br />
<span>weblogic.kernel.ExecuteThread.waitForRequest(ExecuteThread.java:94)</span><br />
<span>at</span><br />
<span>weblogic.kernel.ExecuteThread.run(ExecuteThread.java:118)</span></td>
</tr>
</tbody>
</table>
<table style="width: 600px; color: #ff0000; text-align: left;" border="0" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top"><span style="color: #000000">Threads can be in one of several states.  Please see the <a href="#Analysis_of_Thread_Dump">table</a> below for a description of the thread states.</span><br />
<span style="color: #000000">The format of the thread dump varies with the vendor.  Check on the vendor&#8217;s website for information regarding the format. </span></p>
<p><span style="color: #000000">Below is an example of  threads that  may  be hanging.  ExecuteThread &#8216;9&#8242; is waiting to lock some object &lt;dde51520&gt;.   Notice the &#8220;waiting to lock &lt;dde51520&gt;&#8221; line in the stack trace for this thread.  ExecuteThread &#8216;6&#8242; is also &#8220;waiting to lock the same object &lt;dde51520&gt;&#8221;.  The third thread, ExecuteThread &#8216;5&#8242; has locked this object &lt;dde51520&gt;and is doing work.  This  example demonstrates why one thread dump is not enough.  If the server is hanging, and it is suspected that the cause is the locked object &lt;dde51520&gt;, then subsequent thread dumps will show whether or not that object was released and a new thread has locked object &lt;dde51520&gt;.  If after several thread dumps,  you do not see that the threads have progressed, that object &lt;dde51520&gt; has not been released, you may suspect that there is a problem with the routine(s) in the ExecuteThread &#8216;5&#8242; call stack because the lock is not being released.</span></td>
</tr>
</tbody>
</table>
<table style="width: 600px;" border="1" cellspacing="2" cellpadding="2" width="700">
<tbody>
<tr>
<td style="vertical-align: top; background-color: #cccccc" width="700"><span>&#8220;ExecuteThread: &#8216;9&#8242; for queue: &#8216;weblogic.kernel.Default&#8217;&#8221; daemon prio=5 tid=0xf684c8 nid=0&#215;13 waiting for monitor entry [cc2ff000..cc2ffc24]<br />
at weblogic.cluster.MemberManager.done(MemberManager.java:306)<br />
- waiting to lock &lt;dde51520&gt; (a weblogic.cluster.MemberManager)<br />
at weblogic.cluster.MulticastManager.execute(MulticastManager.java:399)<br />
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)<br />
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)</p>
<p>&#8220;ExecuteThread: &#8216;6&#8242; for queue: &#8216;weblogic.kernel.Default&#8217;&#8221; daemon prio=5 tid=0&#215;9df020 nid=0&#215;10 waiting for monitor entry [cc5ff000..cc5ffc24]<br />
at weblogic.cluster.MemberManager.getRemoteMembers(MemberManager.java:396)<br />
- waiting to lock &lt;dde51520&gt; (a weblogic.cluster.MemberManager)<br />
at weblogic.cluster.ClusterService.getRemoteMembers(ClusterService.java:238)<br />
at weblogic.servlet.internal.HttpServer.setServerList(HttpServer.java:388)<br />
at weblogic.servlet.internal.HttpServer.clusterMembersChanged(HttpServer.java:418)<br />
- locked &lt;ddf32360&gt; (a weblogic.servlet.internal.HttpServer)<br />
at weblogic.cluster.MemberManager$2.execute(MemberManager.java:421)<br />
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)<br />
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)</p>
<p>&#8220;ExecuteThread: &#8216;5&#8242; for queue: &#8216;weblogic.kernel.Default&#8217;&#8221; daemon prio=5 tid=0&#215;9df020 nid=0&#215;12 waiting for monitor entry [cc5ff000..cc5ffc24]<br />
. . .</p>
<p><span> at weblogic.cluster.MemberManager.checkTimeouts(MemberManager.java:346)<br />
- locked &lt;dde51520&gt; (a weblogic.cluster.MemberManager)<br />
at weblogic.cluster.MulticastManager.trigger(MulticastManager.java:291)<br />
at weblogic.time.common.internal.ScheduledTrigger.run(ScheduledTrigger.java:243 </span></p>
<p></span></td>
</tr>
</tbody>
</table>
<table style="width: 600px; text-align: left;" border="0" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top">Determine if the&#8221;default&#8221; ExecuteThread queue is overloaded. Use the console to determine if any of the ExecuteThreads in the ‘default’ queue are idle. If none are idle, then the application probably needs to be configured with a larger number of ExecuteThreads. This value can be changed through the console and is in the <span style="font-family: 'Courier New', Courier, mono;">config.xml</span> file.</p>
<p>If the Execute Queue has idle threads, it is possible that not enough socket reader threads are allocated. By default, a WebLogic Server instance creates three socket reader threads upon booting. If a cluster system utilizes more than three sockets during peak periods, increase the number of socket reader threads.</p>
<p>The number of socket reader threads should usually be small. However, configure one thread for each Weblogic Server that acts as a client of the server instance that is hanging.</p>
<p>If using a JDBC connection pool, ensure that the JDBC connections have been configured to be equivalent to the number of simultaneous requests, i.e., execute threads, for the pool.</p>
<p><span><a href="#TOP">Top of Page</a></span></p>
<p><a name="Known_WebLogic_Server_Issues"></a><br />
The possibility exists that a problem with JDBC could produce deadlock. Check the version and service pack level of the server found in the beginning of the <span style="font-family: 'Courier New', Courier, mono;">weblogic.log</span>. Then check above the version and service pack lines for any temporary patches that have already been applied to the server classpath. The patches will tell what problems have already been addressed.</p>
<p><span><a href="#TOP">Top of Page</a></span></p>
<p><a name="Collecting_Thread_Dumps"></a><br />
The way to take a thread dump is dependent on the operating system where the hung server instance is installed. Information about taking a thread dump on various operating systems can be found at <a href="http://e-docs.bea.com/wls/docs81/cluster/trouble.html#gc">http://e-docs.bea.com/wls/docs81/cluster/trouble.html#gc</a>. Redirection of both standard error and standard out places the thread dump information in the proper context with server information and other messages and provides more useful logs.</p>
<p><em><strong>Unix Systems (Solaris, HP, AIX)</strong></em><br />
Use <span style="font-family: 'Courier New', Courier, mono;">kill –3 &lt;weblogic process id&gt;</span> to create the necessary thread dumps to diagnose a problem. Ensure this is done several times on each server, spaced about 5 to 10 seconds apart, to help diagnose deadlocks. For this to work, nohup the process when starting the server (refer to Solutions <a href="http://support.bea.com/application?namespace=askbea&amp;origin=ask_bea_answer.jsp&amp;event=link.view_answer_page_clfydoc&amp;answerpage=solution&amp;page=wls/S-12292.htm">S-12292</a> and <a href="http://support.bea.com/application?namespace=askbea&amp;origin=ask_bea_answer.jsp&amp;event=link.view_answer_page_clfydoc&amp;answerpage=solution&amp;page=wls/S-15924.htm">S-15924</a>).</p>
<p><em><strong>Windows, XP, NT</strong></em><br />
Each server requires <span style="font-family: 'Courier New', Courier, mono;">&lt;Ctrl&gt;-&lt;Break&gt;</span> to create the necessary thread dumps to diagnose a problem. Ensure this is done several times on each server, spaced about 5 to 10 seconds apart, to help diagnose deadlocks. On NT, in the command shell type <span style="font-family: 'Courier New', Courier, mono;">CTRL-Break</span>.</p>
<p>If you have installed WebLogic as a Windows service, you will not be able to see the messages from the JVM or WebLogic Server that are printed to standard out or standard error.  To view these messages, you must direct standard out and standard error to a file.  To do this, take the following steps:</p>
<ol>
<li>Create a backup copy of the <span style="font-family: 'Courier New', Courier, mono;">WL_HOME\server\bin\installSvc.cmd </span>master script.</li>
<li>In a text editor, open the <span style="font-family: 'Courier New', Courier, mono;">WL_HOME\server\bin\installSvc.cmd </span>master script.</li>
<li>In <span style="font-family: 'Courier New', Courier, mono;">installSvc.cmd</span>, the last command in the script invokes the <span style="font-family: 'Courier New', Courier, mono;">beasvc</span> utility.</li>
<li>At the end of the <span style="font-family: 'Courier New', Courier, mono;">beasvc </span>command, append the command <span style="font-family: 'Courier New', Courier, mono;">-log:&#8221;pathname&#8221;</span><br />
where pathname is a fully qualified path and filename of the file that you want to store the server&#8217;s standard out and standard error messages.</li>
<li>The modified <span style="font-family: 'Courier New', Courier, mono;">beasvc</span> command will resemble the following command:<br />
<span>&#8220;%WL_HOME%\server\bin\beasvc&#8221; -install </span><br />
<span>-svcname:&#8221;%DOMAIN_NAME%_%SERVER_NAME%&#8221; </span><br />
<span>-javahome:&#8221;%JAVA_HOME%&#8221; -execdir:&#8221;%USERDOMAIN_HOME%&#8221; </span><br />
<span>-extrapath:&#8221;%WL_HOME%\server\bin&#8221; -password:&#8221;%WLS_PW%&#8221; </span><br />
<span>-cmdline:%CMDLINE% </span><br />
<span>-log:&#8221;d:\bea\user_projects\domains\myWLSdomain\myWLSserver-stdout.txt&#8221; </span></li>
<li>If you started WebLogic with nohup, the log messages will show up in <span style="font-family: 'Courier New', Courier, mono;">nohup.out</span>.</li>
</ol>
<p><em><strong>Linux</strong></em><br />
The Linux operating system views threads differently than other operating systems. Each thread is seen by the operating system as a process. To take a thread dump on Linux, find the process id from which all the other processes were started. Use the commands:</p>
<ul>
<li>To obtain the root PID, use:<br />
<blockquote><p><span style="font-family: 'Courier New', Courier, mono;">ps -efHl | grep &#8216;java&#8217; **. ** </span></p></blockquote>
</li>
</ul>
<p>Use a grep argument that is a string that will be found in the process stack that matches the server startup command. The first PID reported will be the root process, assuming that the ps command has not been piped to another routine.</p>
<ul>
<li>Use the weblogic.Admin command <span style="font-family: 'Courier New', Courier, mono;">THREAD_DUMP</span></li>
</ul>
<p>Another method of getting a thread dump is to use the <span style="font-family: 'Courier New', Courier, mono;">THREAD_DUMP</span> admin command. This method is independent of the OS on which the server instance is running.</p>
<blockquote><p><span style="font-family: 'Courier New', Courier, mono;">java weblogic.Admin -url ManagedHost:8001 -username weblogic -password weblogic THREAD_DUMP</span></p></blockquote>
<p><strong>NOTE:</strong> This command cannot be used if unable to ping the server instance.</p>
<p>If the JVM in use is Sun’s, the thread dump goes to stdout. Sun has enhanced the thread dump format between JVM 1.3.1 and 1.4. To obtain Sun’s 1.4 style of thread dump add the following option to the java command line for starting the 1.3.1 JVM:</p>
<blockquote><p><span style="font-family: 'Courier New', Courier, mono;">-XX:+JavaMonitorsInStackTrace</span></p></blockquote>
<p><span><a href="#TOP">Top of Page</a></span></p>
<p><a name="Analysis_of_Thread_Dump"></a><br />
The most useful tool in analyzing a server hang is a set of thread dumps. A thread dump provides information on what each of the threads is doing at a particular moment in time. A set of thread dumps (usually 3 or more taken 5 to 10 seconds apart) can help analyze the change or lack of change in each thread’s state from one thread dump to another. A hung server thread dump would typically show little change in thread states from the first to the last dump.</p>
<p>Threads can be in one of the following states:</p>
<table style="width: 600px; height: 171px;" border="1">
<tbody>
<tr>
<td>Running or runnable thread</td>
<td>A runnable state means that the threads could be running or are running at that instance in time.</td>
</tr>
<tr>
<td>Suspended thread</td>
<td>Thread has been suspended by the JVM.</td>
</tr>
<tr>
<td>Thread waiting on a condition variable</td>
<td>Threads in a condition wait state can be thought of as waiting for an event to occur.</td>
</tr>
<tr>
<td>Thread waiting on a monitor lock</td>
<td>Monitors are used to manage access to code that should only be run by a single thread at a time</td>
</tr>
</tbody>
</table>
<p>More information on thread states can be found at<a href="http://java.sun.com/developer/onlineTraining/Programming/JDCBook/stack.html#states"> http://java.sun.com/developer/onlineTraining/Programming/JDCBook/stack.html#states.</a></p>
<p>There is also a thread analysis tool at <a href="http://dev2dev.bea.com/resourcelibrary/utilitiestools/adminmgmt.jsp">http://dev2dev.bea.com/resourcelibrary/utilitiestools/adminmgmt.jsp.</a><br />
Download the tool and read the instructions at the link.<br />
<strong><br />
What to Look at in the Thread Dump</strong><br />
All requests enter the WebLogic Server through the ListenThread. If the ListenThread is gone, no work can be received and therefore no work can be done. Verify that a ListenThread exists in the thread dump. The ListenThread should be in the socketAccept method. The following example shows what the Listen Thread looks like:</td>
</tr>
</tbody>
</table>
<table style="width: 600px;" border="1" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top; background-color: #cccccc"><span>&#8220;ListenThread.Default&#8221; prio=10 tid=0&#215;00037888 nid=93 lwp_id=6888343 runnable [0x 1a81b000..0x1a81b530]</span> <span>at java.net.PlainSocketImpl.socketAccept(Native Method)</span><br />
<span>at</span><br />
<span>java.net.PlainSocketImpl.accept(PlainSocketImpl.java:353)</span><br />
<span>- locked &lt;0&#215;26d9d490&gt; (a java.net.PlainSocketImpl)</span><br />
<span>at</span><br />
<span>java.net.ServerSocket.implAccept(ServerSocket.java:439)</span><br />
<span>at</span><br />
<span>java.net.ServerSocket.accept(ServerSocket.java:410)</span><br />
<span>at</span><br />
<span>weblogic.socket.WeblogicServerSocket.accept(WeblogicServerSocket.java:24)</span><br />
<span>at</span><br />
<span>weblogic.t3.srvr.ListenThread.accept(ListenThread.java:713)</span><br />
<span>at</span><br />
<span>weblogic.t3.srvr.ListenThread.run(ListenThread.java:290)</span></td>
</tr>
</tbody>
</table>
<table style="width: 600px; text-align: left;" border="0" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top">Socket Reader Threads accept the incoming request from the Listen Thread Queue and put it on the Execute Thread Queue. If there are no socket reader threads in the thread dump, then there is a bug somewhere that is causing the socket reader thread to vanish. There should always be at least 3 socket reader threads. One socket reader thread is usually in the poll function, while the other two are available to process requests. Below are Socket Reader threads from a sample thread dump.</td>
</tr>
</tbody>
</table>
<table style="width: 600px;" border="1" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top; background-color: #cccccc"><span>&#8220;ExecuteThread: &#8216;2&#8242; for queue: &#8216;weblogic.socket.Muxer&#8217;&#8221; daemon prio=10 tid=0&#215;000</span> <span>36128 nid=75 lwp_id=6888070 waiting for monitor entry [0x1b12f000..0x1b12f530]</span><br />
<span>at</span><br />
<span>weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:92)</span><br />
<span>- waiting to lock &lt;0&#215;25c01198&gt; (a java.lang.String)</span><br />
<span>at</span><br />
<span>weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:32)</span><br />
<span>at</span><br />
<span>weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)</span><br />
<span>at</span><br />
<span>weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)</span></p>
<p><span>&#8220;ExecuteThread: &#8216;1&#8242; for queue: &#8216;weblogic.socket.Muxer&#8217;&#8221; daemon prio=10 tid=0&#215;000</span> <span>35fc8 nid=74 lwp_id=6888067 runnable [0x1b1b0000..0x1b1b0530]</span> <span>at weblogic.socket.PosixSocketMuxer.poll(Native Method)</span><br />
<span>at</span><br />
<span>weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:99)</span><br />
<span> &#8211; locked &lt;0&#215;25c01198&gt; (a java.lang.String)</span><br />
<span>at</span><br />
<span>weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:32)</span><br />
<span>at</span><br />
<span>weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)</span><br />
<span>at</span><br />
<span>weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)</span></p>
<p><span>&#8220;ExecuteThread: &#8216;0&#8242; for queue: &#8216;weblogic.socket.Muxer&#8217;&#8221; daemon prio=10 tid=0&#215;000</span> <span>35e68 nid=73 lwp_id=6888066 waiting for monitor entry [0x1b231000..0x1b231530]</span><br />
<span>at</span><br />
<span>weblogic.socket.PosixSocketMuxer.processSockets(PosixSocketMuxer.java:92)</span><br />
<span>- waiting to lock &lt;0&#215;25c01198&gt; (a java.lang.String)</span><br />
<span>at</span><br />
<span>weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:32)</span><br />
<span>at</span><br />
<span>weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:178)</span><br />
<span>a</span><span>t</span><br />
<span>weblogic.kernel.ExecuteThread.run(ExecuteThread.java:151)</span></td>
</tr>
</tbody>
</table>
<table style="width: 600px; text-align: left;" border="0" cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td style="vertical-align: top">The <span style="font-family: 'Courier New', Courier, mono;">ThreadPoolPercentSocketReaders</span> attribute sets the maximum percentage of execute threads that are set to read messages from a java socket. The optimal value for this attribute is application-specific. The default value is 33, and the valid range is 1 to 99.</p>
<p>Allocating execute threads to act as socket reader threads increases the speed and the ability of the server to accept client requests. It is essential to balance the number of execute threads that are devoted to reading messages from a socket and those threads that perform the actual execution of tasks in the server.</p>
<p>In release 8.1, the socket reader threads no longer use &#8220;ExecuteThreads&#8221; in the default queue.  Instead they have their own thread group named.</p>
<p><strong>Next Steps</strong><br />
The next steps require a further analysis of the thread dump. Look in the thread dump to see what each the threads are doing at the time of the hang. This will help to analyze the next stage of the investigation. For example, if there are many threads involved in JSP compilation, refer to <a href="#Potential_Causes_of_Server_Hang">Potential Causes of Server Hang</a> for further diagnosis and actions to test.</p>
<p><span><a href="#TOP">Top of Page</a></span></td>
</tr>
</tbody>
</table>
<p><span style="text-decoration: underline;"><span style="color: #669966; font-size: x-small;"> </span></span></p>
<hr /><small>  Copyright &copy; 2008 This feed is for personal, non-commercial use only<br />
<a href=www.hashei.com >聚沙成塔-小哈的记事薄</a> by hashei 
如果喜欢，欢迎订阅<a href=feed.hashei.com >feed.hashei.com</a><br />
Digital Fingerprint:
 10f920a9f2bae51c3c73c4f5fb50a949</small>]]></content:encoded>
			<wfw:commentRss>http://www.hashei.me/2009/08/java_generic_server_hang.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>注册Weblogic9为Windows服务及外一篇</title>
		<link>http://www.hashei.me/2009/08/install-weblogic-as-service-and-recovery-password.html?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=install-weblogic-as-service-and-recovery-password</link>
		<comments>http://www.hashei.me/2009/08/install-weblogic-as-service-and-recovery-password.html#comments</comments>
		<pubDate>Fri, 07 Aug 2009 04:34:23 +0000</pubDate>
		<dc:creator>hashei</dc:creator>
				<category><![CDATA[中间件]]></category>
		<category><![CDATA[weblogic]]></category>
		<category><![CDATA[系统服务]]></category>
		<category><![CDATA[遗忘密码]]></category>

		<guid isPermaLink="false">http://www.hashei.me/2009/08/install-weblogic-as-service-and-recovery-password.html</guid>
		<description><![CDATA[ Weblogic8时代将weblogic注册成为Windows服务是一件很简单的事，只要执行Domain目录下的installService.cmd即可。不过进入Weblogic9之后，domain目录下就没有了那个脚本，而是出现在%WL_HOME%/server/bin下，直接运行会生成一个“bea _”的服务，运行的话。。。没有任何结果，BEA的edocs上也没有找到有用的帮助。
以下内容，是我盯着installService.cmd和startWeblogic.cmd出神良久后试验成功的。


复制一份installServer.cmd到domain目录下，


编辑installServer.cmd，在set WL_HOME=……&#160;&#160; 下添加set DOMAIN_HOME=&#60;你的domain目录&#62;


将下一行的call &#8220;%WL_HOME%\common\bin\commEnv.cmd&#8221;修改成call &#8220;%DOMAIN_HOME%\bin\setDomainEnv.cmd&#8221;（如果这里的setDomainEnv.cmd写完整路径，那么上一步DOMAIN_HOME可以不用设置，因为setDomainEnv.cmd里还会声明一遍的）


另起一行，添加两行“set USERDOMAIN_HOME=%DOMAIN_HOME%”“set DOMAIN_NAME=&#60;你的domain名字&#62;”（这是脚本最末一段Install the service里beasvc命令所需要的参数）


运行installServer.cmd，会在服务里新建一个名为“beasvc %DOMAIN_NAME%_%SERVER_NAME%”的服务，自动运行，帐户属性的是localsystem。


beasvc命令各个参数的详细意义可以参考beasvc /help
以上内容对于Oracle Weblogic 10依旧有效。
weblogic密码遗忘补救方法

备份&#160;&#160; %DOMAIN_HOME%/security下的DefaultAuthenticatorInit.ldift文件，和%DOMAIN_HOME%下的boot.properties文件（如果不在这个目录，那么找找 %DOMAIN_HOME%/servers/AdminServer/security目录），这样如果下列步骤操作失败还能还原回去。
&#160; 运行java -cp /bea/weblogic92/server/lib/weblogic.jar weblogic.security.utils.AdminAccount &#60;新用户名&#62; &#60;新密码&#62; .(注意最后有个点的，点之前有空格，不要和原先的一样)
执行完后在当前目录会生成一个新的DefaultAuthenticatorInit.ldift文件，然后替换原来的%DOMAIN_HOME%/security/DefaultAuthenticatorInit.ldift文件。
从%DOMAIN_HOME%/servers/AdminServer/data/ldap/子目录中删除初始化状态文件DefaultAuthenticatormyrealmInit.initialized，删除boot.properties。
运行startWebLogic.sh，启动过程中会让你输入用户名和密码，输入新建立的那个
用新的用户名密码登录管理控制台，在“安全领域”里点击“myrealm”，在用户和组里，找到之前的那个用户，修改密码，保存，那么以后可以继续使用原来的用户名和密码登录，
修改boot.properties中的用户密码为上一步修改过的用户密码（明文）格式为username=用户名password=密码
重启服务器，现在不用输入用户名密码了，成功启动后，weblogic会加密用户密码的，现在就可以用旧用户登录，新用户可以删除。

Related posts:Business Objects Enterprise3.1、Metedate安装指南Weblogic10.3.0在AIX6.1、JDK1.6下挂起解决方法WebLogic9和10集群安装配置过程服务器备份软件Acronis True Image介绍WebLogic如何更换64位JDK  Copyright &#169; 2008 This feed is for personal, non-commercial use only
聚沙成塔-小哈的记事薄 by hashei 
如果喜欢，欢迎订阅feed.hashei.com
Digital Fingerprint:
 10f920a9f2bae51c3c73c4f5fb50a949]]></description>
			<content:encoded><![CDATA[<p style="text-indent: 24pt"> Weblogic8时代将weblogic注册成为Windows服务是一件很简单的事，只要执行Domain目录下的installService.cmd即可。不过进入Weblogic9之后，domain目录下就没有了那个脚本，而是出现在%WL_HOME%/server/bin下，直接运行会生成一个“bea _”的服务，运行的话。。。没有任何结果，BEA的edocs上也没有找到有用的帮助。</p>
<p style="text-indent: 24pt">以下内容，是我盯着installService.cmd和startWeblogic.cmd出神良久后试验成功的。</p>
<ol>
<li>
<div style="text-indent: 24pt">复制一份installServer.cmd到domain目录下，</div>
</li>
<li>
<div style="text-indent: 24pt">编辑installServer.cmd，在set WL_HOME=……&nbsp;&nbsp; 下添加set DOMAIN_HOME=&lt;你的domain目录&gt;</div>
</li>
<li>
<div style="text-indent: 24pt">将下一行的call &#8220;%WL_HOME%\common\bin\commEnv.cmd&#8221;修改成call &#8220;%DOMAIN_HOME%\bin\setDomainEnv.cmd&#8221;（如果这里的setDomainEnv.cmd写完整路径，那么上一步DOMAIN_HOME可以不用设置，因为setDomainEnv.cmd里还会声明一遍的）</div>
</li>
<li>
<div style="text-indent: 24pt">另起一行，添加两行“set USERDOMAIN_HOME=%DOMAIN_HOME%”“set DOMAIN_NAME=&lt;你的domain名字&gt;”（这是脚本最末一段Install the service里beasvc命令所需要的参数）</div>
</li>
<li>
<div style="text-indent: 24pt">运行installServer.cmd，会在服务里新建一个名为“beasvc %DOMAIN_NAME%_%SERVER_NAME%”的服务，自动运行，帐户属性的是localsystem。</div>
</li>
</ol>
<p style="text-indent: 24pt">beasvc命令各个参数的详细意义可以参考beasvc /help</p>
<p style="text-indent: 24pt">以上内容对于Oracle Weblogic 10依旧有效。</p>
<h4>weblogic密码遗忘补救方法</h4>
<ol>
<li>备份&nbsp;&nbsp; %DOMAIN_HOME%/security下的DefaultAuthenticatorInit.ldift文件，和%DOMAIN_HOME%下的boot.properties文件（如果不在这个目录，那么找找 %DOMAIN_HOME%/servers/AdminServer/security目录），这样如果下列步骤操作失败还能还原回去。
<li>&nbsp; 运行<strong>java -cp /bea/weblogic92/server/lib/weblogic.jar weblogic.security.utils.AdminAccount &lt;新用户名&gt; &lt;新密码&gt; .</strong>(注意最后有个点的，点之前有空格，不要和原先的一样)
<li>执行完后在当前目录会生成一个新的DefaultAuthenticatorInit.ldift文件，然后替换原来的%DOMAIN_HOME%/security/DefaultAuthenticatorInit.ldift文件。
<li>从%DOMAIN_HOME%/servers/AdminServer/data/ldap/子目录中删除初始化状态文件DefaultAuthenticatormyrealmInit.initialized，删除boot.properties。
<li>运行startWebLogic.sh，启动过程中会让你输入用户名和密码，输入新建立的那个
<li>用新的用户名密码登录管理控制台，在“安全领域”里点击“<a href="http://localhost:7001/console/console.portal?_nfpb=true&amp;_pageLabel=RealmgeneralTabPage&amp;SecurityRealmRealmGeneralPortlethandle=com.bea.console.handles.SecurityMBeanHandle%28%22Security%3AName%3Dmyrealm%3Bweblogic.management.security.RealmMBean%22%29">myrealm</a>”，在用户和组里，找到之前的那个用户，修改密码，保存，那么以后可以继续使用原来的用户名和密码登录，
<li>修改boot.properties中的用户密码为上一步修改过的用户密码（明文）格式为<br />username=用户名<br />password=密码
<li>重启服务器，现在不用输入用户名密码了，成功启动后，weblogic会加密用户密码的，现在就可以用旧用户登录，新用户可以删除。</li>
</ol>
<hr /><h2>Related posts:</h2><ul><li><a href="http://www.hashei.me/2009/05/how-to-install-boe3.html" rel="bookmark" title="Permanent Link: Business Objects Enterprise3.1、Metedate安装指南">Business Objects Enterprise3.1、Metedate安装指南</a></li><li><a href="http://www.hashei.me/2009/08/cr370915_in_weblogic10-3_and_jdk1-6.html" rel="bookmark" title="Permanent Link: Weblogic10.3.0在AIX6.1、JDK1.6下挂起解决方法">Weblogic10.3.0在AIX6.1、JDK1.6下挂起解决方法</a></li><li><a href="http://www.hashei.me/2009/09/weblogic-cluster-step-by-step.html" rel="bookmark" title="Permanent Link: WebLogic9和10集群安装配置过程">WebLogic9和10集群安装配置过程</a></li><li><a href="http://www.hashei.me/2009/12/introduction_of_acronis_true_image.html" rel="bookmark" title="Permanent Link: 服务器备份软件Acronis True Image介绍">服务器备份软件Acronis True Image介绍</a></li><li><a href="http://www.hashei.me/2010/05/weblogic%e5%a6%82%e4%bd%95%e6%9b%b4%e6%8d%a264%e4%bd%8djdk.html" rel="bookmark" title="Permanent Link: WebLogic如何更换64位JDK">WebLogic如何更换64位JDK</a></li></ul><hr /><small>  Copyright &copy; 2008 This feed is for personal, non-commercial use only<br />
<a href=www.hashei.com >聚沙成塔-小哈的记事薄</a> by hashei 
如果喜欢，欢迎订阅<a href=feed.hashei.com >feed.hashei.com</a><br />
Digital Fingerprint:
 10f920a9f2bae51c3c73c4f5fb50a949</small>]]></content:encoded>
			<wfw:commentRss>http://www.hashei.me/2009/08/install-weblogic-as-service-and-recovery-password.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

