JBoss Troubleshooting Guide
From Shrubbery
Troubleshooting techniques, solutions and workarounds for JBoss AS.
Contents |
[edit] java.lang.IllegalStateException: Trying to return an unknown connection2!
This is because there is some framework trying to close a JDBC connection during the JTA transaction commit. Spring's Hibernate DAO support does this because it uses thread local Hibernate sessions. In this case, Spring creates a new Hibernate Session and associates a JTA Synchronization object with it and also puts the Session in a thread local. When the JTA transaction commits, the JTA Synchronization is invoked which closes the Hibernate Session before removing it from the thread local. It is at this point that the JBoss JCA code complains.
The workaround is to disable the CachedConnectionInterceptor for all of the relevant EJB types in conf/standardjboss.xml (which configures all the interceptors for the EJB container). Note that in this file there are many different sections identified by a container-name element. You probably will want to keep the CachedConnectionInterceptor for the CMP EJB types, because they should not be using Spring's DAO support.
Here's an example of commenting out the CachedConnectionInterceptor for stateless session EJBs:
<container-configuration>
<container-name>Standard Stateless SessionBean</container-name>
<call-logging>false</call-logging>
<invoker-proxy-binding-name>stateless-http-invoker</invoker-proxy-binding-name>
<container-interceptors>
...
<!-- <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor> -->
- Here is the official answer on the JBoss JCA FAQ: http://wiki.jboss.org/wiki/Wiki.jsp?page=IGetquotTryingToReturnAnUnknownConnection2quotError
- Here is the main thread: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=58525
- http://www.jboss.org/?module=bb&op=viewtopic&p=3832604
- http://www.jboss.org/?module=bb&op=viewtopic&p=3867145
- http://www.jboss.org/index.html?module=bb&op=viewtopic&t=59294
[edit] JMS/JDBC Connections being closed automatically
By default the Tomcat configuration in JBoss will close all JCA connections made during a web request when the request finishes. If you expect to use a JMS/JDBC connection across multiple requests this behavior will break your code.
Fortunately, it can be disabled very easily. See JBoss CachedConnectionValve
[edit] OutOfMemoryError: PermGen
JBoss applications that use EJBs and Hibernate will do a lot of dynamic class generation, which can use up a lot of the 'PermGen' JVM memory. The simple solution is to just increase the PermGen space using JVM options. Here is an example for a Sun Java 1.5 JVM:
-XX:MaxPermSize=128m -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
This will double the PermGen size from the default of 64M, but it can be increased. The other options allow the JVM to clean up unused classes, although I have not experienced this
See also:
- http://jira.jboss.com/jira/browse/JASSIST-28 - Upgrading javassist and hibernate will get rid of permgen OOMEs caused by Hibernate.
- Understanding PermGen errors (part1)
- Understanding PermGen errors (part2)
- Good Riddance, PermGen OutOfMemoryError ! and PermGen Strikes Back!

