Subject | Re: 'Cannot provide new connection' error in EJB3 EAR app on Glassfish 2.1 (Sun) |
---|---|
Author | Roman Rokytskyy |
Post date | 2009-04-23T20:43:29Z |
Hi,
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.
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
> 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:The code you have posted is part of the connection pool logic. There are
> '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;
> }'
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,You must be mixing something. Firebird can handle multiple connections
> 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?
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