环境:
weblogic816,(192.168.0.55)
mysql 5.0.41-community-nt-log(192.168.0.10)
1、启动mysql和weblogic,配置jdbc连接池,如下图:
2、连接池测试成功,如下图:
3、配置数据源
4、部署测试的应用程序sql,测试后报错
<Sep 2, 2010 10:57:17 PM EDT> <Error> <HTTP> <BEA-101249> <[ServletContext(id=11801206,name=sql,context-path=/sql)]: Servlet class com.sql.tool.test2 for servlet test2 could not be loaded because the requested class was not found in the classpath /home/bea/sql/WEB-INF/classes:/home/bea/bea814/user_projects/domains/mydomain/./myserver
/.wlnotdelete/extract/myserver_sql_sql/jarfiles/WEB-INF/lib/mysql-connector-java-3.1.11-bin.jar:/home/bea/bea814/user_projects/domains/mydomain/./myserver
/.wlnotdelete/extract/myserver_sql_sql.
java.lang.UnsupportedClassVersionError: com/sql/tool/test2 (Unsupported major.minor version 49.0).>
<Sep 2, 2010 10:57:17 PM EDT> <Error> <HTTP> <BEA-101018> <[ServletContext(id=11801206,name=sql,context-path=/sql)] Servlet failed with ServletException
javax.servlet.ServletException: [HTTP:101249][ServletContext(id=11801206,name=sql,context-path=/sql)]: Servlet class com.sql.tool.test2 for servlet test2 could not be loaded because the requested class was not found in the classpath /home/bea/sql/WEB-INF/classes:/home/bea/bea814/user_projects/domains/mydomain/./myserver
/.wlnotdelete/extract/myserver_sql_sql/jarfiles/WEB-INF/lib/mysql-connector-java-3.1.11-bin.jar:/home/bea/bea814/user_projects/domains/mydomain/./myserver
/.wlnotdelete/extract/myserver_sql_sql.
java.lang.UnsupportedClassVersionError: com/sql/tool/test2 (Unsupported major.minor version 49.0).
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:905)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:598)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:406)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
>
这个错误在网上搜了半天,是JDK版本的问题,由于我编译时用的是1.5的JDK,但是weblogic8是跑在1.4上,所以会报错。
于是重新将程序导入myeclipse,切换JDK,如下图:
但是自动编译后,上传程序后发现仍然报错。
用file命令看了下我的class文件:
[bea@mylinux tool]$ file test2.class
test2.class: compiled Java class data, version 49.0
很奇怪,为什么还是49了,49的意思是用1.5的JDK编译的
研究了半天才发现,原来在Myeclipse上,还需把一个地方给调整一下,如下图:
这个地方默认的编译器仍然是1.5!修改成1.4后,重新自动编译就OK了,如下重新上传到linux上后
[bea@mylinux ~]$ file test2.class
test2.class: compiled Java class data, version 46.0
[bea@mylinux ~]$
5、重新部署程序后,展开测试,如下图:
显示出了student表里所有的数据,在MYSQL-FRONT查询
6、打开连接池泄露监控的参数(一共3个),如下图:
7、设置连接池的最大数
8、连续点击测试页面5次以上后,开始出现等待的连接,如下:
标准输出里开始出现告警:
<Sep 3, 2010 11:08:02 AM EDT> <Warning> <HTTP> <BEA-101248> <[Application: '/home/bea', Module: 'sql']: Deployment descriptor “web.xml” is malformed. Check against the DTD: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘web-app’. (line 6, column 54).>
Unable to load driver.
weblogic.jdbc.extensions.PoolLimitSQLException: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool MyJDBC Connection Pool to allocate to applications, please increase the size of the pool and retry..
at weblogic.jdbc.common.internal.JDBCUtil.wrapAndThrowResourceException(JDBCUtil.java:205)
at weblogic.jdbc.pool.Driver.connect(Driver.java:161)
at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:546)
at weblogic.jdbc.jts.Driver.connect(Driver.java:140)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:344)
at com.sql.tool.test2.doGet(test2.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
Unable to load driver.
weblogic.jdbc.extensions.PoolLimitSQLException: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool MyJDBC Connection Pool to allocate to applications, please increase the size of the pool and retry..
at weblogic.jdbc.common.internal.JDBCUtil.wrapAndThrowResourceException(JDBCUtil.java:205)
at weblogic.jdbc.pool.Driver.connect(Driver.java:161)
at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:546)
at weblogic.jdbc.jts.Driver.connect(Driver.java:140)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:344)
at com.sql.tool.test2.doGet(test2.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
9、首先weblogic在30秒后会强制回收连接,然后显示连接池泄露的代码
<Sep 3, 2010 11:45:51 AM EDT> <Warning> <Common> <BEA-000620> <Forcibly releasing inactive resource “weblogic.jdbc.common.internal.ConnectionEnv@1e47d66″ back into the pool “MyJDBC Connection Pool”.>
<Sep 3, 2010 11:45:51 AM EDT> <Warning> <Common> <BEA-000620> <Forcibly releasing inactive resource “weblogic.jdbc.common.internal.ConnectionEnv@1b4f377″ back into the pool “MyJDBC Connection Pool”.>
<Sep 3, 2010 11:46:54 AM EDT> <Warning> <JDBC> <BEA-001074> <A JDBC pool connection leak was detected. A connection leak occurs when a connection obtained from the pool was not closed explicitly by calling close() and then was disposed by the garbage collector and returned to the connection pool. The following stack trace at create shows where the leaked connection was created. Stack trace at connection create:
at weblogic.jdbc.wrapper.PoolConnection.init(PoolConnection.java:75)
at weblogic.jdbc.pool.Driver.allocateConnection(Driver.java:254)
at weblogic.jdbc.pool.Driver.connect(Driver.java:164)
at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:546)
at weblogic.jdbc.jts.Driver.connect(Driver.java:140)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:344)
at com.sql.tool.test2.doGet(test2.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
>
<Sep 3, 2010 11:46:54 AM EDT> <Warning> <JDBC> <BEA-001074> <A JDBC pool connection leak was detected. A connection leak occurs when a connection obtained from the pool was not closed explicitly by calling close() and then was disposed by the garbage collector and returned to the connection pool. The following stack trace at create shows where the leaked connection was created. Stack trace at connection create:
at weblogic.jdbc.wrapper.PoolConnection.init(PoolConnection.java:75)
at weblogic.jdbc.pool.Driver.allocateConnection(Driver.java:254)
at weblogic.jdbc.pool.Driver.connect(Driver.java:164)
at weblogic.jdbc.jts.Driver.getNonTxConnection(Driver.java:546)
at weblogic.jdbc.jts.Driver.connect(Driver.java:140)
at weblogic.jdbc.common.internal.RmiDataSource.getConnection(RmiDataSource.java:344)
at com.sql.tool.test2.doGet(test2.java:76)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1077)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:465)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
注:在代码中我注释掉了Conn.close()
while (RS.next()) {
out.println(RS.getString(“id”) + ” ” + RS.getString(“name”));
}
RS.close();
Stmt.close();
//Conn.close();