`

XApool连接池报空指针错误解决

    博客分类:
  • Java
阅读更多
at org.enhydra.jdbc.pool.GenericPool.getFromPool(GenericPool.java:200) 
at org.enhydra.jdbc.pool.GenericPool.checkOut(GenericPool.java:351) 
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:194) 
at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164) 
at my.jotm.test.Client.getConnection(Client.java:63) 
java.sql.SQLException: SQLException in StandardPoolDataSource:getConnection exception: java.sql.SQLException: SQLException in  
StandardPoolDataSource:getConnection no connection available java.lang.NullPointerException

 
发现这是XApool1.5的一个bug

解决方法:

--- xapool/org/enhydra/jdbc/pool/GenericPool.java-1.13 2005-06-14 21:57:10.756790600 -0500 
+++ xapool/org/enhydra/jdbc/pool/GenericPool.java 2005-06-15 13:11:09.601072300 -0500 
@@ -189,6 +189,12 @@ 
     
       o = (GenerationObject) e.nextElement(); 
       life = (Long) unlocked.get(o); 
+      if (life == null) { 
+   // Fix for #303462; note that this fixes the problem, but Enumeration's on Hashtable's  
+   // are by definition somewhat unpredictable; a more robust fix may be in order 
+   log.debug("GenericPool:getFromPool fix for #303462 encountered"); 
+   continue; 
+      } 
       unlocked.remove(o); 
       // In any case the object will be removed. 
       // Prevents others accessing the object while we are 

 

 

下载xapool源码包,然后在org.enhydra.jdbc.pool.GenericPool中,找到life = (Long) unlocked.get(o); 代码

之后在下面加入:

 

if (life == null)  continue; 

 

之后重新编译打包即可。

 

注:xapool1.5是在jdk1.4的版本下编译的,所以记得在打包修改时,将IDE的J2SE版本改为1.4。

 

 

以下提供我已经编译好的jar包,使用中如果看到bad version的错误,请自行编译。

分享到:
评论
5 楼 LAFEU 2013-12-10  
3Q!
4 楼 eppen 2013-01-14  
官方的xapool 1.6beta版本已经修正了该问题,以及其他问题。

http://xapool.ow2.org/
3 楼 bjyzxxds 2012-05-03  
问题解决,非常感谢
2 楼 无花果 2012-02-22  
大神,谢谢你! 
1 楼 helloklzs 2011-04-25  
很有效,谢谢了

相关推荐

Global site tag (gtag.js) - Google Analytics