Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-38478

SqlService.transact() fails with SQLException if callback calls SqlService.dbInsert()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Critical
    • Resolution: Duplicate
    • Affects Version/s: 2.7.x
    • Fix Version/s: None
    • Component/s: Kernel
    • Labels:
      None
    • Previous Issue Keys:
      KNL-571

      Description

      When using transactions with SqlService - using SqlService.transact(Runnable callback, String tag) - transaction can be aborted (with a SQLException) if the caller calls SqlService.dbInsert() on the callback. This happens because a change between Kernel 1.0.x and 1.1.0 causes the connection on SqlService.dbInsert() to be returned (SqlService.returnConnection()) even if dbInsert was called on a transaction (this doesn't happen in 1.0.x):

      The fix if super-simple, and I will attache a patch to this issue on the following minutes.

      When the described scenario above happens, the stacktrace similar to the following is logged:

      org.sakaiproject.portal.api.PortalHandlerException: org.sakaiproject.tool.api.ToolException: Servlet execution threw an exception
      at org.sakaiproject.portal.charon.handlers.ToolHandler.doPost(ToolHandler.java:73)
      caused by: org.sakaiproject.tool.api.ToolException: Servlet execution threw an exception
      at org.sakaiproject.portal.charon.SkinnableCharonPortal.forwardTool(SkinnableCharonPortal.java:1221)
      caused by: javax.servlet.ServletException: Servlet execution threw an exception
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      caused by: java.lang.Error: java.sql.SQLException: Connection is closed.
      at org.sakaiproject.db.impl.BasicSqlService.transact(BasicSqlService.java:409)
      caused by: java.sql.SQLException: Connection is closed.
      at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.checkOpen(PoolingDataSource.java:175)
      at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:180)
      at org.sakaiproject.db.impl.BasicSqlService.returnConnection(BasicSqlService.java:276)
      at org.sakaiproject.db.impl.BasicSqlService.transact(BasicSqlService.java:409)
      at org.etudes.mneme.impl.PoolStorageSql.insertPool(PoolStorageSql.java:317)
      at org.etudes.mneme.impl.PoolStorageSql.savePool(PoolStorageSql.java:213)
      at org.etudes.mneme.impl.PoolServiceImpl.doCopyPool(PoolServiceImpl.java:600)
      at org.etudes.mneme.impl.PoolServiceImpl.copyPool(PoolServiceImpl.java:147)
      at org.etudes.mneme.tool.PoolsView.post(PoolsView.java:247)
      at org.etudes.ambrosia.util.AmbrosiaServlet.doPost(AmbrosiaServlet.java:222)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.sakaiproject.util.RequestFilter.doFilter(RequestFilter.java:585)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:659)
      at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:457)
      at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:359)
      at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:311)
      at org.sakaiproject.tool.impl.ActiveToolComponent$MyActiveTool.forward(ActiveToolComponent.java:500)
      at org.sakaiproject.portal.charon.SkinnableCharonPortal.forwardTool(SkinnableCharonPortal.java:1221)
      at org.sakaiproject.portal.charon.handlers.ToolHandler.doTool(ToolHandler.java:204)
      at org.sakaiproject.portal.charon.handlers.ToolHandler.doGet(ToolHandler.java:96)
      at org.sakaiproject.portal.charon.handlers.ToolHandler.doPost(ToolHandler.java:73)
      at org.sakaiproject.portal.charon.SkinnableCharonPortal.doPost(SkinnableCharonPortal.java:1064)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.sakaiproject.util.RequestFilter.doFilter(RequestFilter.java:646)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
      at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:444)
      at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:472)
      at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1293)
      at java.lang.Thread.run(Thread.java:619)

        Gliffy Diagrams

          Zeplin

            Attachments

              Issue Links

                Activity

                  People

                  • Assignee:
                    k1team KERNEL TEAM (Inactive)
                    Reporter:
                    nfernandes Nuno Fernandes (Inactive)
                  • Votes:
                    0 Vote for this issue
                    Watchers:
                    1 Start watching this issue

                    Dates

                    • Created:
                      Updated:
                      Resolved:

                      Git Integration