国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > Tomcat > 正文

解決tomcat頻繁死掉的問題

2024-09-06 19:01:05
字體:
供稿:網(wǎng)友

某天在服務(wù)器上的網(wǎng)頁打不開了,頻繁報以下錯誤。

2007-3-18 1:08:26 org.apache.tomcat.util.threads.threadpool logfull
嚴(yán)重: all threads (150) are currently busy, waiting. increase maxthreads (150) or check the servlet status

在網(wǎng)上找了些回答,以下是我覺得正確的回答:
1.我想你的部分資源沒有釋放,積壓卡死的
2.連接池問題
3.應(yīng)該是服務(wù)器端響應(yīng)request的線程的處理時間過長導(dǎo)致的

分析:
當(dāng)時使用網(wǎng)站的人數(shù)只有2個人,不可能答到到了并發(fā)線程150的上線。所以應(yīng)該不是數(shù)據(jù)庫的問題。
通過對出錯的提示判斷,應(yīng)該是連接池使用不合理造成的,或者根本沒設(shè)置連接池。和數(shù)據(jù)庫連接的部分是使用spring的數(shù)據(jù)源jdbc連的,如下:
<beans>
    <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource">
        <!-- driver for mysql-->
        <property name="driverclassname"><value>org.gjt.mm.mysql.driver</value></property>
        <property name="url"><value>jdbc:mysql://localhost:3306/test?useunicode=true&amp;characterencoding=utf8</value></property>
        <property name="username"><value>test</value></property>
        <property name="password"><value>test</value></property>      
</beans>

問題應(yīng)該出現(xiàn)在spring的drivermanagerdatasource上,它負(fù)責(zé)管理這些連接的。
下邊是對drivermanagerdatasource 的解釋
drivermanagerdatasource in spring framework

   javax.sql interface datasource

implementation of smartdatasource that configures a plain old jdbc driver via
bean properties, and returns a new connection every time.

useful for test or standalone environments outside of a j2ee container, either
as a datasource bean in a respective applicationcontext, or in conjunction with
a simple jndi environment. pool-assuming connection.close() calls will simply
close the connection, so any datasource-aware persistence code should work.

in a j2ee container, it is recommended to use a jndi datasource provided by the
container. such a datasource can be exported as a datasource bean in an
applicationcontext via jndiobjectfactorybean, for seamless switching to and from
a local datasource bean like this class.

if you need a "real" connection pool outside of a j2ee container, consider
apache's jakarta commons dbcp. its basicdatasource is a full connection pool
bean, supporting the same basic properties as this class plus specific settings.
it can be used as a replacement for an instance of this class just by changing
the class name of the bean definition to
"org.apache.commons.dbcp.basicdatasource".

-----------------------------------------------
many jakarta projects support interaction with a relational database. creating a
new connection for each user can be time consuming (often requiring multiple
seconds of clock time), in order to perform a database transaction that might
take milliseconds. opening a connection per user can be unfeasible in a
publicly-hosted internet application where the number of simultaneous users can
be very large. accordingly, developers often wish to share a "pool" of open
connections between all of the application's current users. the number of users
actually performing a request at any given time is usually a very small
percentage of the total number of active users, and during request processing is
the only time that a database connection is required. the application itself
logs into the dbms, and handles any user account issues internally.

there are several database connection pools already available, both within
jakarta products and elsewhere. this commons package provides an opportunity to
coordinate the efforts required to create and maintain an efficient,
feature-rich package under the asf license.

the commons-dbcp package relies on code in the commons-pool package to provide
the underlying object pool mechanisms that it utilizes.

applications can use the commons-dbcp component directly or through the existing
interface of their container / supporting framework. for example the tomcat
servlet container presents a dbcp datasource as a jndi datasource. james (java
apache mail enterprise server) has integrated dbcp into the avalon framework. a
avalon-style datasource is created by wrapping the dbcp implementation. the
pooling logic of dbcp and the configuration found in avalon's excalibur code is
what was needed to create an integrated reliable datasource.

看完了解釋,事實上是因為drivermanagerdatasource建立連接是只要有連接就新建一個connection,根本沒有連接池的作用。改為以下開源的連接池會好點。
<bean id="mydatasource" class="org.apache.commons.dbcp.basicdatasource" destroy-method="close">
<property name="driverclassname">
<value>org.hsqldb.jdbcdriver</value>
</property>
<property name="url">
<value>jdbc:hsqldb:hsql://localhost:9001</value>
</property>
<property name="username">
<value>sa</value>
</property>
<property name="password">
<value></value>
</property>
</bean>

測試通過,問題消除,如果沒有搜索引擎找答案不會這么快解決問題。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 许昌市| 榕江县| 沿河| 水富县| 屏东县| 拜城县| 怀化市| 白河县| 新乡县| 南陵县| 阿图什市| 富川| 连江县| 涟水县| 分宜县| 班玛县| 怀化市| 义马市| 元朗区| 独山县| 新干县| 微博| 柳江县| 桐梓县| 香港| 抚松县| 仁化县| 汶川县| 桃园市| 勐海县| 前郭尔| 肇东市| 安新县| 阜新| 思茅市| 会昌县| 吴旗县| 黎川县| 岑溪市| 丹江口市| 安西县|