Subject Re: 'Cannot provide new connection' error in EJB3 EAR app on Glassfish 2.1 (Sun)
Author meinhardt.baer
Sun app server has connection pool and I am using the values:
datasource classname: org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource
resource type:
javax.sql.ConnectionPoolDataSource

And this connection pool is then used by JDBC data source. I guess - the only option is to change org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource but what other value can I use - I guess, it can be the same as on other J2EE server like JBoss (it should have JDBC data source and connection pool as well).

--- In Firebird-Java@yahoogroups.com, Roman Rokytskyy <roman@...> wrote:
>
> Hi,
>
> > I am trying to develop EAR application (EJB3, web modulues) on Glassfish 2.1, NB6.5.1 and FB 1.5.x and Java Server Faces (actually ICEFaces, the best option, I guess). I managed to create EJB's from database, to compile applciation and to deploy on the server, but when I am trying to view the page that has query 'SELECT o from CUSTOMER', where customer is my EJB - mapped to customers tables, I am getting:
> > 'Caused by: java.lang.IllegalStateException: Cannot provide new connection while old one is still in use.
> > at org.firebirdsql.pool.AbstractPingablePooledConnection.getConnection(AbstractPingablePooledConnection.java:345)
> > at com.sun.gjc.spi.ManagedConnection.getActualConnection(ManagedConnection.java:572)
> > at com.sun.gjc.spi.ManagedConnection.getConnection(ManagedConnection.java:326)
> > at com.sun.enterprise.resource.LocalTxConnectorAllocator.fillInResourceObjects(LocalTxConnectorAllocator.java:100)'
> >
> > I can see this in the Jaybird code - here it is:
> > ' /**
> > * Get JDBC connection corresponding to this pooled connection instance.
> > *
> > * @return instance of {@link Connection}
> > *
> > * @throws SQLException if some error happened.
> > */
> > public
> > Connection getConnection() throws SQLException {
> >
> > checkValidity();
> >
> > checkInPool();
> >
> > if (currentConnection !=ull) {
> >
> > throw new IllegalStateException(
> > "Cannot provide new connection while old one is still in use.");
> >
> > //currentConnection.close();
> > }
> >
> > currentConnection =ew PooledConnectionHandler(jdbcConnection, this);
> >
> > Connection result =urrentConnection.getProxy();
> >
> > configureConnectionDefaults(result);
> >
> > return result;
> > }'
>
> The code you have posted is part of the connection pool logic. There are
> two connections when the application uses connection pooling - physical
> connection and "logical" connection. The call DataSource.getConnection()
> or ManagedConnection.getConnection() returns a logical connection.
>
> The error you see means that application (or application server) tried
> to obtain the logical connection while the previous was not closed. In
> other words the application tried to obtain two connections from the
> same physical connection, which, AFAIK, should not be allowed.
>
> > Well - I cannot find now, but I have sense that I have read somewhere,
> > that there can be support only for single connection in Jaybird or
> > something like this, so - can I achieve my goal to use Firebird in
> > J2EE EJB3.0 app with Jaybird?
>
> You must be mixing something. Firebird can handle multiple connections
> without any problem. There were some issues with multithreaded access to
> the same connection object, but they should be gone now and this is not
> the case in EJBs anyway - there is one request per thread.
>
> So, the error you see is somehow related to the configuration of the
> data source in the application server itself. I, however, never used Sun
> Application Server, so hardly can help you here...
>
> Roman
>