On 10 March 2011 18:50, Filip Hanik - Dev Lists <devli...@hanik.com> wrote:
> On 3/9/2011 11:57 PM, Eiji Takahashi wrote:
>>
>> Hi developers.
>>
>> I encountered the same issue, too.
>> I got following exception.
>
> an exception is expected if the connection has been abandoned.
> it's tricky, one can always throw a SQLException, which leads to a problem,
> what if a method is called that does not throw SQLException. we can check
> for this as well

Letting the JVM generate an NPE does not immediately alert the user to
the cause of the problem.

Why not throw IllegalStateException with a suitable message?

> best
> Filip
>
>
>> -----
>> java.lang.NullPointerException
>>         at
>> org.apache.tomcat.jdbc.pool.interceptor.StatementCache$CachedStatement.closeInvoked(StatementCache.java:224)
>>         at
>> org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor$StatementProxy.invoke(StatementDecoratorInterceptor.java:226)
>>         at $Proxy1.close(Unknown Source)
>>         at test.PoolTestServlet.doPost(PoolTestServlet.java:30)
>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
>>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>>         at
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
>>         at
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>         at
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
>>         at
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
>>         at
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
>>         at
>> org.apache.catalina.ha.tcp.ReplicationValve.invoke(ReplicationValve.java:354)
>>         at
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:108)
>>         at
>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:558)
>>         at
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>>         at
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:379)
>>         at
>> org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:283)
>>         at
>> org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:209)
>>         at
>> org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1671)
>>         at
>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>         at
>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>         at java.lang.Thread.run(Thread.java:662)
>> ---
>> When the busy connection reaches abandoned time-out, PoolCleaner calls
>> ConnectionPool#abandon() for this connection.
>> And, reset all Interceptors that is relevant to this connection. In
>> the case of StatementCache, null is set to cacheSize and pcon.
>> As a result, when CachedStatement.closeInvoked is executed,
>> cacheSize.get() causes NPE.
>> I think that other Interceptors also have same issue.
>>
>> I thought several solutions for this issue.
>> (1) Prevent NPE at each Interceptors.
>> (2) Create new interceptor for handling NPE, and set this interceptor
>> to top of interceptor chain.
>>     ->  In this interceptor, change RuntimeException to SQLException.
>>
>> I think that (2) is better than (1), because (2) doesn't depend on
>> design of each Interceptors.
>>
>>
>> On Thu, Mar 10, 2011 at 2:09 PM, Keiichi Fujino<kfuj...@apache.org>
>>  wrote:
>>>
>>> 2011/3/4 Filip Hanik - Dev Lists<devli...@hanik.com>:
>>>>
>>>> Source and Binary Packages
>>>> http://people.apache.org/~fhanik/jdbc-pool/v1.1.0.1/
>>>>
>>>> Tag
>>>> http://svn.apache.org/repos/asf/tomcat/tags/JDBC_POOL_1_1_0_1/
>>>>
>>>> Documentation
>>>> http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html
>>>>
>>>> The proposed 1.1.0.1 release is:
>>>>
>>>> [ ] Broken - do not release
>>>> [ ] Alpha  - go ahead and release as 1.1.0.1 Alpha
>>>> [ ] Beta   - go ahead and release as 1.1.0.1 Beta
>>>> [X] Stable - go ahead and release as 1.1.0.1 Stable
>>>
>>> I tested jdbc-pool with simple applications.
>>> And it works well.
>>>
>>> However, when setting removeAbandoned="true", NPE is thrown out.
>>> It seems to occur when the Abandoned processing and SQL execution
>>> processing are executed at the same time.
>>> The synchronization of the Pool-Cleaner thread might not work
>>> correctly though I am not checking the code.
>>>
>>> The following are logs.
>>> =====localhost.2011-03-10.log
>>> Mar 10, 2011 1:24:23 PM org.apache.catalina.core.StandardWrapperValve
>>> invoke
>>> SEVERE: Servlet.service() for servlet [jdbc] in context with path
>>> [/test] threw exception
>>> java.lang.NullPointerException
>>>    at
>>> org.apache.tomcat.jdbc.pool.ProxyConnection.invoke(ProxyConnection.java:125)
>>>    at $Proxy9.prepareStatement(Unknown Source)
>>>    at jdbc_pool.JDBCPoolServlet.doGet(JDBCPoolServlet.java:32)
>>>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
>>>    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
>>>    at
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
>>>    at
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
>>>    at
>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
>>>    at
>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
>>>    at
>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
>>>    at
>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
>>>    at
>>> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve..java:562)
>>>    at
>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>>>    at
>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394)
>>>    at
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
>>>    at
>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler..process(Http11Protocol.java:188)
>>>    at
>>> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
>>>    at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>>>    at
>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>>>    at java.lang.Thread.run(Thread.java:619)
>>> =====
>>>
>>> --
>>> Keiichi.Fujino
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>
>>
>>
>> -----
>> No virus found in this message.
>> Checked by AVG - www.avg.com
>> Version: 10.0.1204 / Virus Database: 1497/3496 - Release Date: 03/10/11
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to