I have found several posts documenting the IllegalStateException from the
CachedConnectionInterceptor when developers do not adhere to J2EE semantics.
Most of the posts were centered around Hibernate 2 using a Thread Local
Pattern.
I have a case where a bean managed SessionBean (no transaction used) uses
another bean managed SessionBean that gets a Hibernate session, performs a
query, closes the connection and I get errors below. This is perfectly legal
and adheres to J2EE semantics
What?s interesting is I see this problem using JBoss Portal 2.2, AS 4.0.3sp1,
Hibernate 3.0.2, but not while using JBoss Portal 2.0, AS 4.0.1, Hibernate
3.0.2. And to add to the mystery the JBoss 2.2 Bundle (with AS 4.0.3sp1) did
not come with Hibernate. However JBoss 4.0.3sp1 come bundled with Hibernate
3.1.rc2.
Error Messages:
[CachedConnectionManager] Closing a connection for you. Please close them
yourself: [EMAIL PROTECTED]
java.lang.Throwable: STACKTRACE
at
org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:333)
10:57:54,937 INFO [TxConnectionManager] throwable from unregister connection
java.lang.IllegalStateException: Trying to return an unknown connection2!
[EMAIL PROTECTED]
at
org.jboss.resource.connectionmanager.CachedConnectionManager.unregisterConnection(CachedConnectionManager.java:385)
First Session bean:
protected String createProfileInternal(Entity e, Profile p) throws
ProfileException {
try {
DataServicesLocal dataServices =
dataServicesLocalHome.create();
VersionedModelBase vmb = profileToPojo(e, p);
String query = SQLGenerator.getEntityByProfile(e, p);
ModelBase model = dataServices.uniqueQuery(query);
if (model != null) {
throw new DuplicateProfileException();
}
dataServices.save( vmb );
return vmb.getGuid();
} catch (ProfileException pe) {
throw pe;
} catch (Exception other) {
log.error("createProfileInternal: error occurred while
creating new profile", other);
throw new ProfileException(other.getMessage());
}
}
Second Session bean:
public ModelBase uniqueQuery(String queryString) throws EJBException {
// find a unique result based on the input query
Session session = getSession();
ModelBase result = null;
try {
Query query = session.createQuery(queryString);
result = (ModelBase)query.uniqueResult();
} catch (HibernateException e) {
String message = "DataServices: uniqueQuery failed: " +
queryString;
log.error(message, e);
}
finally {
session.close();
}
return result;
}
protected Session getSession() {
Session session = null;
try {
SessionFactory sf = (SessionFactory) new
InitialContext()
.lookup(SESSION_FACTORY);
session = session = sf.openSession();
session.connection().setAutoCommit(false);
return session;
} catch (NamingException e) {
log.error(e);
throw new RuntimeException("DataServicesBean: Cannot
get Hibernate session.");
} catch (SQLException e) {
String message = "DataServices: SQLException: " +
e.getMessage();
log.error(message, e);
}
return session;
}
Thanks in advance for any help with this problem.
P.S. I'm planning to upgrade to Hibernate 3.1 to see if this problem ges away.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3922994#3922994
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3922994
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user