8 Replies Latest reply on Jun 9, 2009 3:48 PM by spotlight2001

    "Connection is not associated with a managed connection", Ca

    spotlight2001

      I moved a legacy app (jboss328SP1 hibernate 2x) to a jboss501ga.

      datasource type:
      <local-tx-datasource>

      In my tests no errors. In production (only with a lot of users) I encountered:

      Connection is not associated with a managed connection.org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6@7cb375d0
      


      interpretation: over jdbc connection, a jboss connection is wrapped
      but the wrapper is empty. the original jdbc connection inside is no longer there. (according to the jboss5 source)


      in the log I found more information above:

      Closing a connection for you. Please close them yourself
      


      interpretation:
      org.jboss.resource.connectionmanager.CachedConnectionInterceptor
      this class is charged with closing connections which it thinks are no longer needed.


      So what can I do? In my test-environment I am unable to reproduce these errors.

      Q1) How can I reproduce such an error in my test environment.

      Q2) Will these params help (postgres) against "Connection is not associated with a managed connection"?
      <new-connection-sql>select 1</new-connection-sql>
      <check-valid-connection-sql>select 1</check-valid-connection-sql>
      <min-pool-size>5</min-pool-size>
      <max-pool-size>20</max-pool-size>
      <idle-timeout-minutes>10</idle-timeout-minutes>


      Any ideas where to search for an answer?

      I used google.




      2009-05-28 11:13:37,414 [http-0.0.0.0-443-9] ERROR at.iqsoft.vokappl.web.action.LogonAction - Fatal error trying to obtain BIN for the card
      at.iqsoft.vokappl.service.persistence.common.PersistenceException: Query creation error
      at at.iqsoft.vokappl.service.persistence.hibernate.BinDAOHibernate.findBinByBIN(BinDAOHibernate.java:64)
      at at.iqsoft.vokappl.web.action.LogonAction.logon(LogonAction.java:172)
      at sun.reflect.GeneratedMethodAccessor295.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
      at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
      at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
      at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
      at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
      at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:104)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:619)
      2009-05-28 11:13:39,829 [http-0.0.0.0-443-9] ERROR net.sf.hibernate.transaction.JDBCTransaction - Begin failed
      java.sql.SQLException: Connection is not associated with a managed connection.org.jboss.resource.adapter.jdbc.jdk6.WrappedConnectionJDK6@7cb375d0
      at org.jboss.resource.adapter.jdbc.WrappedConnection.lock(WrappedConnection.java:81)
      at org.jboss.resource.adapter.jdbc.WrappedConnection.getAutoCommit(WrappedConnection.java:468)
      at net.sf.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:40)
      at net.sf.hibernate.transaction.JDBCTransactionFactory.beginTransaction(JDBCTransactionFactory.java:19)
      at net.sf.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:2252)
      at at.iqsoft.vokappl.web.action.LogoffAction.logout(LogoffAction.java:53)
      at sun.reflect.GeneratedMethodAccessor308.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      


        • 1. Re:
          ahameed

          Hi

          I am facing similar kind of a problem. Same exception, not reproducible on development machine. Using JBoss 4.3.0.GA.

          Please do share if you find any solution to this.

          Thanks

          • 2. Re:
            spotlight2001

            on prod are more users. I tried JMeter but couldnt reproduce the error.

            My next steps:

            1) old jboss ALSO has the same INTERCEPTOR in config. I will download the source and compare whether the old jboss also has the "close connection for you" inside.

            2) Maybe its some autocommit issue. I will check that too.

            3) last resort: on production server - turning on the log (like in this forum faq in this section). on trace.

            • 3. Re:
              ahameed

              Hi

              I commented the CachedConnectionValve at end of the server.xml file.

              Also commented the CachedConnectionManager in META-INF/jboss-service.xml.

              The "Connection is not associated with a managed connection" is gone and application is running fine.

              By the way, this warning appears when there are unclosed connections.
              <track-statements>false</track-statements> in datasource .xml file would help hide warnings if statements are not closed.

              Hope it helps.

              • 4. Re:
                adrian.brock

                Read the FAQ. What you are doing is an anti-pattern and will cause connection leaks.

                • 5. Re:
                  andy.miller

                   

                  "adrian@jboss.org" wrote:
                  Read the FAQ. What you are doing is an anti-pattern and will cause connection leaks.


                  Could you point me to the specific FAQ you are referring to? I see the same problem in the Apache Day Trader application (IBM wrote it). I may have to fix the application, but I'm not that familiar with it yet.

                  Thanks.

                  • 6. Re:
                    jaikiran
                    • 7. Re:
                      andy.miller

                       

                      "jaikiran" wrote:
                      I guess the "Thread Local Pattern" in this FAQ http://www.jboss.org/community/wiki/WhatDoesTheMessageDoYourOwnHousekeepingMean


                      Thanks Jaikiran!

                      • 8. Re:
                        spotlight2001

                        thanks for the info of the valve and the link.

                        The valve shutdown seems to "solve" the problem. No complaints so far. You rock!

                        I inherited the application. Stone age Hibernate2 + Threadlocal. Additional JDBC queries are wrapped in finally blocks. No money for a rewrite of course :-)