7 Replies Latest reply on Apr 8, 2009 12:28 PM by Rafael Soares (Tuelho)

    ResourceException messages improve

    Rafael Soares (Tuelho) Novice

      Hello all.

      When i get this exception is possible know what DataSource throw the Exception?
      There is any configuration on log4j for JBoss Connection Manager log the name of resource throw those exception types? I think this is trivial to do, but i don't know if is possible do it with a simple configuration on JBoss services.

      javax.resource.ResourceException: No ManagedConnections available within configured blocking timeout ( 30000 [ms] )
       at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:301)
       at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:500)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:347)
       at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:330)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:402)
       at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:849)
       at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:90)
      


        • 1. Re: ResourceException messages improve
          Peter Johnson Master

          Is there more to the stack trace? Somewhere in the stack trace should be some of your code, what datasource was that code attempting to get?

          You could try setting the log level to trace for org.jboss.resource.connectionmanager, some of htose classes have trace-level logging.

          • 2. Re: ResourceException messages improve
            Rafael Soares (Tuelho) Novice

            Yes, the stack trace contains the indication (methd name and line number) where exception occur on application's code. But sometimes the app use/refer more than one DS and JBoss AS admin. doesn't have access to code to verify what DS the app refer to.

            Would be very interesting if by default ConnectionManager could print resource name on stack trace. I production env this functionality would be very useful for admins.

            May be a JIRA to request this behavior? :-)

            About trace-level logging, it is not useful in production env.

            regards

            • 3. Re: ResourceException messages improve
              Adrian Brock Master

              Raise a feature request or better yet provide a patch.

              It looks like a trivial change to me in
              org.jboss.resource.connectionmanager.InternalManagedConnectionPool

              - throw new ResourceException("No ManagedConnections available within configured blocking timeout ( "
               + poolParams.blockingTimeout + " [ms] )");
              + throw new ResourceException(jcmp.getPoolJndiName() + " - no ManagedConnections available within configured blocking timeout ( "
               + poolParams.blockingTimeout + " [ms] )");
              


              I guess there's other places that would benefit from it as well?

              • 4. Re: ResourceException messages improve
                Peter Johnson Master

                I would gladly open a JIRA and attach a patch, but once again I find that I have just read-only access to JIRA - I cannot create new issues, nor comment on existing issues. So Adrian, could you open a JIRA? The patch follows (should be good for 5.0.x and 5.1.x):

                Index: BaseConnectionManager2.java
                ===================================================================
                --- BaseConnectionManager2.java (revision 86861)
                +++ BaseConnectionManager2.java (working copy)
                @@ -438,7 +438,7 @@
                 }
                
                 // If we get here all retries failed, throw the lastest failure
                - throw failure;
                + throw new ResourceException("Unable to get managed connection for datasource " + jndiName, failure);
                 }
                
                 public void returnManagedConnection(ConnectionListener cl, boolean kill)


                I could not get the the code in InternalManagedConnectionPool to add in the JNDI name because it did not know it. Based on Eclipse, and on the compiler, the only way to get to InternalManagedConnectionPool.getConnection() is from BaseConnectionManager2.getManagedConnection() (via ConnectionListener.getConnection()). Of those three, only BaseConnectionManager2 knew the JNDI name. The choice was either passing the JNDI name along (by changing the method signatures) or adding the name in at BaseConnectionManager2. Then I noticed that BaseConnectionManager2.getManagedConnection rethrows the exceptions it catches and that make it easy to layer on another exception which did name the data source.

                Here is an example of the exception:

                2009-04-06 14:03:29,169 DEBUG [org.hibernate.util.JDBCExceptionReporter] (http-127.0.0.1-8080-3) Cannot open connection [???]
                org.jboss.util.NestedSQLException: Unable to get managed connection for datasource jdbc/jsfDS; - nested throwable: (javax.resource.ResourceException: Unable to get managed connection for datasource jdbc/jsfDS)
                 at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
                 at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46)
                 ***lots of lines deleted***
                 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
                 at java.lang.Thread.run(Thread.java:619)
                Caused by: javax.resource.ResourceException: Unable to get managed connection for datasource jdbc/jsfDS
                 at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:441)
                 at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:381)
                 at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)
                 at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
                 at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
                 ... 91 more
                Caused by: javax.resource.ResourceException: No ManagedConnections available within configured blocking timeout ( 10000 [ms] )
                 at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:295)
                 at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:644)
                 at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:404)
                 ... 95 more


                • 5. Re: ResourceException messages improve
                  jaikiran pai Master

                   

                  "PeterJ" wrote:
                  I would gladly open a JIRA and attach a patch, but once again I find that I have just read-only access to JIRA - I cannot create new issues, nor comment on existing issues.

                  https://jira.jboss.org/jira/browse/JBAS-6752

                  • 7. Re: ResourceException messages improve
                    Rafael Soares (Tuelho) Novice

                    Thanks all!

                    This will be very useful!