[jboss-user] [JCA/JBoss] - Re: ResourceException messages improve

PeterJ do-not-reply at jboss.com
Mon Apr 6 17:22:30 EDT 2009

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- 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

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4223811#4223811

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4223811

More information about the jboss-user mailing list