tomcat频繁死掉的问题

2016-02-19 19:27 69 1 收藏

下面图老师小编要跟大家分享tomcat频繁死掉的问题,简单的过程中其实暗藏玄机,还是要细心学习,喜欢还请记得收藏哦!

【 tulaoshi.com - Web开发 】

  某天在服务器上的网页打不开了,频繁报以下错误。

  2007-3-18 1:08:26 org.apache.tomcat.util.threads.ThreadPool logFull
  严重: All threads (150) are currently busy, waiting. Increase maxThreads (150) or check the servlet status

  在网上找了些回答,以下是我觉得正确的回答:
  1.我想你的部分资源没有释放,积压卡死的
  2.连接池问题
  3.应该是服务器端响应request的线程的处理时间过长导致的

  分析:
  当时使用网站的人数只有2个人,不可能答到到了并发线程150的上线。所以应该不是数据库的问题。
  通过对出错的提示判断,应该是连接池使用不合理造成的,或者根本没设置连接池。和数据库连接的部分是使用Spring的数据源JDBC连的,如下:
  beans
      bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          !-- driver for MySQL--
          property name="driverClassName"valueorg.gjt.mm.mysql.Driver/value/property
          property name="url"valuejdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF8/value/property
          property name="username"valuetest/value/property
          property name="password"valuetest/value/property      
  /beans

  问题应该出现在Spring的DriverManagerDataSource上,它负责管理这些连接的。
  下边是对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.

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

  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.

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

  看完了解释,事实上是因为DriverManagerDataSource建立连接是只要有连接就新建一个connection,根本没有连接池的作用。改为以下开源的连接池会好点。
  bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
  property name="driverClassName"
  valueorg.hsqldb.jdbcDriver/value
  /property
  property name="url"
  valuejdbc:hsqldb:hsql://localhost:9001/value
  /property
  property name="username"
  valuesa/value
  /property
  property name="password"
  value/value
  /property
  /bean

  测试通过,问题消除,如果没有搜索引擎找答案不会这么快解决问题。

来源:https://www.tulaoshi.com/n/20160219/1621042.html

延伸阅读
------------------- Tomcat 5中文问题 author:kiss__sky@163.com ------------------- 问题描述: 1 表单提交的数据,用request.getParameter(“xxx”)返回的字符串为乱码或者?? 2 直接通过url如http://localhost/a.jsp?name=中国,这样的get请求在服务端用request. getParameter(“...
标签: windows系统
解决Win8.1频繁重启问题有绝招   第一:属性--高级系统设置--启动和故障恢复 这一栏,单击设置--取消勾选的自动重新启动,确定,保存设置。 第二:取消鼠标和键盘唤醒主机的选项,注意,不是唤醒屏幕,是唤醒主机!win8.1默认是勾选的。去除即可。 方法:这台计算机---右键管理---设备管理器---键盘---PS/2标准键...
标签: Web开发
1、配置系统管理(Admin Web Application) 大多数商业化的J2EE服务器 都提供一个功能强大的管理界面,且大都采用易于理解的Web应用界面。Tomcat按照自己的方式,同样提供一个成熟的管理工具,并且丝毫不逊于那些商业 化的竞争对手。Tomcat的Admin Web Application最初在4.1版本时出现,当时的功能包括管理context、data source、user...
今天遇见了这个端口被占用问题 然后各种百度 先是说 用命令 netstat -a -n -o 最后一个选项表示连接所在进程id. 找到8080端口的PID然后打开任务管理器, 切换到进程选项卡, 在菜单栏选择查看-选择列, 选择PID. 在列表中找到PID对应的进程就可以了然后发现占用端口的进程的PID为4 可无奈如何关闭都关闭不了这个进程 于是又百度了pid为4的进程 果...
宝宝胎动频繁正常吗     胎动怎么一回事呢? 胎动,是妈妈感知 胎儿 最好的途径了,孕妈妈到了孕中期胎动会开始比较的频繁,但是到了孕晚期,胎 宝宝 的身形都发育的完整了,活动的空间也就变的小了,所以一般孕妈妈在孕晚期会很少感知到宝宝的动静。 怀孕28周起胎动的次数会逐渐的相...

经验教程

516

收藏

7
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部