views:

103

answers:

1

Occasionally, I get following exception when running my Java EE application with Glassfish:

Error in allocating a connection. Cause: java.lang.IllegalStateException: 
Local transaction already has 1 non-XA Resource: cannot add more resources.

The application uses a single JDBC connection pool that is not XA-capable. However, I was not yet been able to identify the second resource that causes the exception.

Is there a way to debug/log transactions with Glassfish 2.1?

Something that would help me identifying the offending non-XA resource would be of great help.

A: 

You can enable the logging of JTA / JTS in the log level of the admin console, plus other log levels (I don't remember exactly which ones are available). The debug information that is produced is however quite cryptic.

But your issue is quite strange. XA resource can be database connection, jms connection or connection from jca connectors. If you have only one datasource, this would mean that you try to obtain two connections for the same datasource during one transaction. Normally, the application server optimizes this case and serves the same physical connection twice when you try to obtain it from the datasource -- but maybe this optimization is not done in your case.

So if I were you I would try to enable the logging that shows when connection are obtained, and try to spot in the code also all potential places where a connection might be fetched from the pool either directly with a lookup, or indirectly by injection or through a framework (e.g. JPA).

As a last resort, you can also try to enable "Allow non-component callers" in the datasource configuration, maybe it helps.

That also reminded me of this other question: “Local transaction already has 1 non-XA Resource: cannot add more resources” error

Hope it helps.

ewernli