[ http://issues.apache.org/jira/browse/IBATIS-152?page=all ]

Sven Boden updated IBATIS-152:
------------------------------

    Attachment: PreparedStatementLogProxy.diff
                StatementLogProxy.diff

I installed GNU diff on my PC. Attached to "diff -u" files to fix IBATIS-142, 
the patch may also possibly fix IBATIS-152 (pretty sure), IBATIS-149 and maybe 
IBATIS-116, all depending on the exact stack-traces generated by the latter 
bugs.

The root cause for IBATIS-142 is that when that the proxy class 
PreparedStatementLogProxy (when logging is on) always wraps a ResultSet in a 
ResultSetLogProxy even when the original ResultSet is null. The effect of this 
is that later on when close() of the ResultSet is called ResultSetLogProxy 
tries to call the close method on the original "null" result with the 
NullPointerException as result.

The solution is to only return a ResultSetLogProxy when the result is not 
empty, and null otherwise. This way the logging version of the functionality is 
in sync with the non-logging version.

StatementLogProxy is included as it uses the same way of wrapping ResultSets 
and it may cause similar problems.

If anyone is interested in receiving the full file for 
PreparedStatementLogProxy for testing purposes, let me know.

Regards,
Sven Boden
[EMAIL PROTECTED]

> NullPointer Exception thrown in GeneralStatement.executeQueryWithCallback 
> when using Log4j
> ------------------------------------------------------------------------------------------
>
>          Key: IBATIS-152
>          URL: http://issues.apache.org/jira/browse/IBATIS-152
>      Project: iBatis for Java
>         Type: Bug
>   Components: SQL Maps
>     Versions: 2.1.1
>  Environment: Windows XP, Java 1.3
>     Reporter: David Winterbottom
>  Attachments: PreparedStatementLogProxy.diff, PreparedStatementLogProxy.diff, 
> PreparedStatementLogProxy.java, RefCursor.zip, StatementLogProxy.diff
>
> Hi,
> I am trying to follow the supplied test for IBATIS-53 (Oracle ref cursors).
> I have found that running the supplied test (number 6) with log4j-1.2.9.jar 
> on 
> the classpath causes a NullPointerException.
> The stack trace and output is:
> DEBUG [main] - Created connection 3235124.
> DEBUG [main] - {conn-100000} Connection
> DEBUG [main] - {pstm-100001} PreparedStatement: { ? = call 
> mis_extract.mgr_case_temp.FindCases }
> DEBUG [main] - {pstm-100001} Parameters: []
> DEBUG [main] - {pstm-100001} Types: []
> DEBUG [main] - {rset-100002} ResultSet
> DEBUG [main] - Returned connection 3235124 to pool.
> com.ibatis.common.jdbc.exception.NestedSQLException:   
> --- The error occurred in com/kinnect/mis/datamodel/sql/CaseToExtract.xml.  
> --- The error occurred while applying a parameter map.  
> --- Check the output.  
> --- Check the output parameters (retrieval of output parameters failed).  
> --- Cause: java.lang.NullPointerException
> Caused by: java.lang.NullPointerException
>       at 
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:184)
>       at 
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:100)
>       at 
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
>       at 
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
>       at 
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:97)
>       at 
> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:69)
>       at com.kinnect.mis.MISExtract.readCasesToExtract(MISExtract.java:233)
>       at com.kinnect.mis.MISExtract.main(MISExtract.java:64)
> Caused by: 
> java.lang.NullPointerException
>       at java.lang.reflect.Method.invoke(Native Method)
>       at 
> com.ibatis.common.jdbc.logging.ResultSetLogProxy.invoke(ResultSetLogProxy.java:47)
>       at $Proxy2.close(Unknown Source)
>       at 
> com.ibatis.sqlmap.engine.execution.SqlExecutor.closeResultSet(SqlExecutor.java:392)
>       at 
> com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(SqlExecutor.java:298)
>       at 
> com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecuteQuery(ProcedureStatement.java:34)
>       at 
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:169)
>       at 
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:100)
>       at 
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:561)
>       at 
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:536)
>       at 
> com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:97)
>       at 
> com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:69)
>       at com.kinnect.mis.MISExtract.readCasesToExtract(MISExtract.java:233)
>       at com.kinnect.mis.MISExtract.main(MISExtract.java:64)
> Is there a known problem with log4j with IBatis ?
> Is this a problem for RefCursors only ?

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to