Subject Re: [Firebird-Java] IllegalStateException
Author David Jencks
Can you provide more detail on what causes the original exception? Is it
creating the prepared statement? Is autocommit on or, if not, how are you
controlling transactions?

thanks
david jencks

On 2003.05.13 04:53 Juan Pedro López Sáez wrote:
> I'm getting in trouble with the following exception in my JSP code:
>
> java.lang.IllegalStateException: Can't destroy managed connection with
> active transaction
>
> After executing a preparedStatement, I close it in order to return the
> database connection to the pool, even if the preparedStatement thows a
> SQLException.
> When this happens, the close method throws another exception because
> there is nothing to close at all. It doesn't matter because I catch the
> SQLException too.
>
> After that, I close the database connection, as usual. But in this
> situation , I get the IllegalStateException.
>
> Is there anything wrong with my code? Why does the system crash after
> closing a wrong preparedStatement?
>
> I attach below the full exception message.
>
> Thank you in advance.
>
> Juan Pedro.
>
> -----------------------------------------------------
> org.apache.jasper.JasperException: Can't destroy managed connection
> with active transaction
>
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
> at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
> at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
> at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:430)
> at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:498)
> at org.apache.jsp.login_jsp._jspService(login_jsp.java:188)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
> at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
> at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
> at java.lang.Thread.run(Thread.java:536)
>
> root cause
>
> java.lang.IllegalStateException: Can't destroy managed connection with
> active transaction
> at org.firebirdsql.jca.FBManagedConnection.destroy(FBManagedConnection.java:319)
> at org.firebirdsql.jca.FBStandAloneConnectionManager.connectionClosed(FBStandAloneConnectionManager.java:66)
> at org.firebirdsql.jca.FBManagedConnection.notify(FBManagedConnection.java:735)
> at org.firebirdsql.jca.FBManagedConnection.close(FBManagedConnection.java:599)
> at org.firebirdsql.jdbc.FBConnection.close(FBConnection.java:448)
> at com.altiria.wasp.mktSMS.beans.ConnectionBean.close(Unknown
> Source)
> at org.apache.jsp.error_jsp._jspService(error_jsp.java:78)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
> at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
> at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
> at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:430)
> at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:498)
> at org.apache.jsp.login_jsp._jspService(login_jsp.java:188)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
> at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
> at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
> at java.lang.Thread.run(Thread.java:536)
>
>
> --
> Juan Pedro López Sáez
> ALTIRIA TIC, S.L.L.
> www.altiria.com
> Centro de Empresas "La Arboleda"
> Carretera NIII km. 7,300 - Campus Sur
> 28031 MADRID
> Teléfono/Fax 91 33 111 98
> Móvil 610 258 837
> jpls@...
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
> <HTML>
> <HEAD>
> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
> <META NAME="GENERATOR" CONTENT="GtkHTML/1.1.10">
> </HEAD>
> <BODY>
>
>
> I'm getting in trouble with the following exception in my JSP code:<BR>
> <BR>
> java.lang.IllegalStateException: Can't destroy managed connection with
> active transaction<BR>
> <BR>
> After executing a preparedStatement, I close it in order to return the
> database connection to the pool, even if the preparedStatement thows a
> SQLException. <BR>
> When this happens, the close method throws another exception because
> there is nothing to close at all. It doesn't matter because I catch the
> SQLException too.<BR>
> <BR>
> After that, I close the database connection, as usual. But in this
> situation , I get the IllegalStateException.<BR>
> <BR>
> Is there anything wrong with my code? Why does the system crash after
> closing a wrong preparedStatement? <BR>
> <BR>
> I attach below the full exception message.<BR>
> <BR>
> Thank you in advance.<BR>
> <BR>
>     Juan Pedro. <BR>
> <BR>
> -----------------------------------------------------<BR>
> org.apache.jasper.JasperException: Can't destroy managed connection with
> active transaction
> <PRE> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:248)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
> at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
> at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
> at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:430)
> at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:498)
> at org.apache.jsp.login_jsp._jspService(login_jsp.java:188)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
> at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
> at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
> at java.lang.Thread.run(Thread.java:536)</PRE>
> <FONT COLOR="#ffffff" SIZE="3"><B>root cause</B></FONT>
> <PRE>java.lang.IllegalStateException: Can't destroy managed connection
> with active transaction
> at org.firebirdsql.jca.FBManagedConnection.destroy(FBManagedConnection.java:319)
> at org.firebirdsql.jca.FBStandAloneConnectionManager.connectionClosed(FBStandAloneConnectionManager.java:66)
> at org.firebirdsql.jca.FBManagedConnection.notify(FBManagedConnection.java:735)
> at org.firebirdsql.jca.FBManagedConnection.close(FBManagedConnection.java:599)
> at org.firebirdsql.jdbc.FBConnection.close(FBConnection.java:448)
> at com.altiria.wasp.mktSMS.beans.ConnectionBean.close(Unknown
> Source)
> at org.apache.jsp.error_jsp._jspService(error_jsp.java:78)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
> at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
> at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
> at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:430)
> at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:498)
> at org.apache.jsp.login_jsp._jspService(login_jsp.java:188)
> at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:204)
> at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
> at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
> at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
> at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
> at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
> at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
> at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
> at java.lang.Thread.run(Thread.java:536)</PRE>
> <BR>
> <TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
> <TR>
> <TD>
> <PRE>--
> Juan Pedro López Sáez
> ALTIRIA TIC, S.L.L.
> www.altiria.com
> Centro de Empresas "La Arboleda"
> Carretera NIII km. 7,300 - Campus Sur
> 28031 MADRID
> Teléfono/Fax 91 33 111 98
> Móvil 610 258 837
> jpls@...</PRE>
> </TD>
> </TR>
> </TABLE>
>
>
> <br>
>
> <!-- |**|begin egp html banner|**| -->
>
> <table border=0 cellspacing=0 cellpadding=2>
> <tr bgcolor=#FFFFCC>
> <td align=center><font size="-1" color=#003399><b>Yahoo! Groups
> Sponsor</b></font></td>
> </tr>
> <tr bgcolor=#FFFFFF>
> <td align=center width=470><a href="http://rd.yahoo.com/M=251812.3170658.4537139.1261774/D=egroupweb/S=1705006764:HM/A=1564416/R=0/*http://www.netflix.com/Default?mqso=60164797&partid=3170658"><img
> src="http://us.a1.yimg.com/us.yimg.com/a/ne/netflix/yhoo0303_b_300250a.gif"
> alt="" width="300" height="250" border="0"></a></td>
> </tr>
> <tr><td><img alt="" width=1 height=1
> src="http://us.adserver.yahoo.com/l?M=251812.3170658.4537139.1261774/D=egroupmail/S=:HM/A=1564416/rand=898019668"></td></tr>
> </table>
>
> <!-- |**|end egp html banner|**| -->
>
>
> <br>
> <tt>
> To unsubscribe from this group, send an email to:<BR>
> Firebird-Java-unsubscribe@yahoogroups.com<BR>
> <BR>
> </tt>
> <br>
>
> <br>
> <tt>Your use of Yahoo! Groups is subject to the <a
> href="http://docs.yahoo.com/info/terms/">Yahoo! Terms of
> Service</a>.</tt>
> </br>
>
> </BODY>
> </HTML>
>