Tag Archives: Xapool

[JOTM+Xapool] xapool 이용 시 Null Pointer Exception 문제 해결

사용자 삽입 이미지서로 다른 데이터 소스를 하나로 묶어 트랜젝션을 이용할 수 있게 해주는 멋진 라이브러리로 JOTM이라는 것이 있습니다.

보통은 JOTM + Xapool 조합으로 사용하게 됩니다. 하지만 사실 이 둘의 라이브러리는 시대에 많이 뒤떨어지는 것이 아닐까 하는 생각이 듭니다.

둘다 업데이트가 2년이 넘게 없어왔기 때문입니다. 이쯤 되면 이 오픈소스 프로젝트들은 사실상 더이상 이어지지 않는다고 봐도 되겠죠.

그 예로 Xapool의 마지막 stable 버젼인 1.5.0에는 치명적인 문제가 한가지 있습니다. 물론 1.6.0beta 버젼에서 해결은 되었긴 하지만 beta버젼보다는 안전한 stable버젼을 이용하고픈 마음이 들기 마련이죠.

[code]java.lang.NullPointerException


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


at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:213)


at org.enhydra.jdbc.pool.StandardPoolDataSource.getConnection(StandardPoolDataSource.java:164)[/code]
위의 에러 어떠십니까? 마음에 들어 보이십니까? 이와 같은 Null Pointer Exception 에러를 내뿜는 에러를 만날 수 있습니다.

위의 에러는 Xapool에서 내는 에러인데요. [이곳]에 관련 패치가 등록 되어있습니다.

1290343559.patch


이 패치의 내용은 다음과 같습니다. 커넥션을 얻어올때 특정한 상황에 따라 Null을 받아오게 되면 다음의 보관된 논리적인 커넥션을 얻어오도록 넘어가는 처리만 추가되었습니다.

[code]— 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
[/code]
실제로 해당 패치를 적용한 후에는 관련 문제점이 발견되지 않았습니다. 혹시 귀찮으신 분들을 위해 패치된 버젼을 올려둡니다.
1000564104.jar