Bitter bites with Java

JBoss5 exception: “Adding multiple last resources is disallowed..”

Posted by: Venugopal S on: February 11, 2009

Hi,

Some of you might have come across the following strange exception when moving to Jboss5 from Jboss4.x.

Adding multiple last resources is disallowed. Current resource is [EMAIL
PROTECTED]
| 16:17:18,000 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: null
| 16:17:18,000 ERROR [JDBCExceptionReporter] Could not enlist in transaction
on entering meta-aware object!; – nested throwable:
(javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist
resource, see the previous warnings. tx=TransactionImple < ac, BasicAction:
-53e0d9e7:77e:469b7d96:41 status: ActionStatus.ABORT_ONLY >); – nested
throwable: (org.jboss.resource.JBossResourceException: Could not enlist in
transaction on entering meta-aware object!; – nested throwable:
(javax.transaction.SystemException: java.lang.Throwable: Unabled to enlist
resource, see the previous warnings. tx=TransactionImple < ac, BasicAction:
-53e0d9e7:77e:469b7d96:41 status: ActionStatus.ABORT_ONLY >))
| 16:17:18,000 FATAL [application] javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: Cannot open connection
| javax.faces.el.EvaluationException: javax.persistence.PersistenceException:
org.hibernate.exception.GenericJDBCException: Cannot open connection

This happens when :

1. You have 2 EAR files in a single server instance. Not just 2 ear files, but from within a transaction of a deployed EAR file, when you try to access the other EAR file, get some data from there and try to commit the transaction. This is not allowed in arjuna API (AFAIK). To fix this, edit JBOSS_HOME/server/default/conf/jbossjta-properties.xml and add the following line

<property name=”com.arjuna.ats.jta.allowMultipleLastResources” value=”true” />

The problem does not stop here..The datasource has to support it.

Modify the *ds.xml to look like this ( localtxdatasource would not work) :

<?xml version=”1.0″ encoding=”UTF-8″?>
<datasources>
<xa-datasource>
<jndi-name>CatMgrDS</jndi-name>
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
<xa-datasource-property name=”URL”>jdbc:mysql://192.168.157.57:3306/30cm</xa-datasource-property>
<xa-datasource-property name=”User”>root</xa-datasource-property>
<xa-datasource-property name=”Password”>root</xa-datasource-property>
<!– the minimum size of the connection pool –>
<min-pool-size>1</min-pool-size>
<!– The maximum connections in a pool/sub-pool –>
<max-pool-size>4</max-pool-size>
</xa-datasource>
</datasources>

Next step is to make sure you have the latest version of mysql-connector(in my case atleast). Versions prior to 5.1.10 doesn’t support XA datasource(ref :http://marc.info/?l=kandula-dev&m=113945114400475&w=2) I replaced my old mysql connector with the latest one.

Things should work fine then. will keep this writing up to date to my best possible extent :)




7 Responses to "JBoss5 exception: “Adding multiple last resources is disallowed..”"

This can be fixed otherwise too :

For e.g., if you are using Stateful Session beans, you can refactor the code to use separate transactions. If you simply need to read from one DataSource and insert processed results into another, you may not want or need 2-phase commit (and thus the above optimization). In an EJB3 stateful session bean, this can be accomplished by simply delegating the read to a separate method and annotating it with “@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)”. This causes the calling method’s Transaction to suspend, wait for the read to complete, and resume.

Unfortunately i am not using Stateful session beans..all our beans are stateless.

[...] had another JBoss hack and he was able to fix one more issue that may bubble up during the migration from JBoss 4.x to 5. [...]

But, does it really have anything to do with jboss 5? Xa datasource would imply that 2 phase commits are supported.

[...] friend Venu had a post in his blog on how to fix it in JBoss 5.0. You can read it here. But if we are using JBoss 5.1.0 this solution cannot help us. Because there are a couple of [...]

This solution cannot help us if we are working with 5.1.0.GA. There are a lot of changes in JBoss5.1.0.GA configurations compared to 5.0.0 GA. Read this: http://javabeanz.wordpress.com/2009/06/18/a-jboss-5-1-0-exception/

Hi all,

That was not enough for Jboss 5.1.0 GA. Boy o Boy it sucks..Migrating from Jboss 4.0.5 to Jboss 5.0.0 was a nightmare by itself. No peace ! Again from 5.0.0 to 5.1.0 they have changed things left to right. We have to live with it anyways :) Community edition :)

As i had mentioned in my first point above, editing JBOSS_HOME/server/default/conf/jbossjta-properties.xml is not possible in Jboss 5.1.0 coz it’s no more .

What the heck do i do then? No worries folks! Just look for jbossts-properties.xml in the same folder location and look for the block “”. Change the value from “NO” to “YES”.

Happy coding ..

jbossjta-properties.xml is present in JBOSS_HOME/checkout folder.

Check it out !

Leave a Reply


  • whitelassiblog: jbossjta-properties.xml is present in JBOSS_HOME/checkout folder. Check it out !
  • Subinkrishna G: Hi Kuldeep, We (me & venu) were using Jboss 4 before migrating to 5.0 and then to 5.1. I don't have much idea about migrating from 3.x to 5.x.
  • Kuldeep: Hello, I'm migrating application from Jboss 3.2.6 to Jboss 5.1.0 GA. I've used EJB 2, Message Driven Beans, Hibernate. Could you please give

Categories

Archives