Hi, i have the same problem, i'm using JBoss 3.2.1 and PostgreSQL 7.3.2, i have some CMP beans, they work flawlessly, but when I try to get a connection in a Session bean I get the same error.
Connection con = ( (DataSource)new InitialContext().lookup("java:/PostgreSQL") ).getConnection();
stmt = con.createStatement();
rs = stmt.executeQuery("select nextval(\'"+sequenceName+"\')");
the goddamn exception:
java.lang.IllegalStateException: Trying to return an unknown connection1!
org.jboss.resource.adapter.jdbc.WrappedConnection@13b64eb at org.jboss.resource.connectionmanager.CachedConnectionManager.unregisterConnection(CachedConnectionManager.java:264) at org.jboss.resource.connectionmanager.TxConnectionManager$TxConnectionEventListener.connectionClosed(TxConnectionManager.java:550)
Please, I need some help! :)
Thanks in advance,
The only time I got these errors was when I was trying to open a connection before closing existing ones. As soon as I fixed that, the errors went away.
My guess is that maybe one the entity beans is still busy using the datasource while you are asking to for another connection.
I am using Jboss 3.0.7
Thanks a lot!!
I got the same exception "Trying to return unknown connection1" and found a way to prevent it.
I'm using JBoss 3.2.1 with MySQL on windows. I implemented the DAC pattern as published by Floyd Marinescu (using a stateful session bean which uses JDBC).
My first version looked like this (in the original version Floyd used preparedStatements of course):
public abstract class BaseUpdateCommand
protected Statement stmt;
private Connection con;
protected BaseUpdateCommand (String jndiName)
ctx = new InitialContext ();
ds = (javax.sql.DataSource)ctx.lookup (jndiDSName);
con = ds.getConnection ();
stmt = con.createStatement ();
public long execute (String statement)
updateCount = stmt.executeUpdate (statement);
This code has always thrown exceptions - even when used in a single-threaded test scenario. Only when I moved the createStatement and the getConnection statements into the execute-method all exceptions vanished.
Now I'm mystified - any idea what happened ?
I am pissed off, I have the same problem. I spent hours to find out that this is a JBOSS issue as you all suggesated. Is this how JBOSS makes money. Charging support to fix their problem. I am discussed.