java.lang.ArrayIndexOutOfBoundsException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • https://bugzilla.redhat.com/show_bug.cgi?id=1035216 is also reproducible in wildfly. {code} WARN [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA016009: Caught:: java.lang.ArrayIndexOutOfBoundsException: 0 at org.jboss.as.ejb3.remote.EJBTransactionRecoveryService.getXAResources(EJBTransactionRecoveryService.java:114) at com.arjuna.ats.internal.jbossatx.jta.XAResourceRecoveryHelperWrapper.getXAResources(XAResourceRecoveryHelperWrapper.java:51) [narayana-jts-integration-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:516) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkFirstPass(XARecoveryModule.java:182) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:743) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] {code} I think the line 111 "new XAResource\[receiverContexts.size()\]" should be placed inside synchronized block. {code:java|title=ejb3/src/main/java/org/jboss/as/ejb3/remote/EJBTransactionRecoveryService.java} 109 @Override 110 public XAResource[] getXAResources() { 111 final XAResource[] xaResources = new XAResource[receiverContexts.size()]; 112 synchronized (receiverContexts) { 113 for (int i = 0; i < receiverContexts.size(); i++) { 114 xaResources[i] = EJBClientManagedTransactionContext.getEJBXAResourceForRecovery(receiverContexts.get(i), arjunaTxCoreEnvironmentBean.getValue().getNodeIdentifier()); 115 } 116 } 117 return xaResources; 118 } ... 124 @Override 125 public void receiverRegistered(final EJBReceiverContext receiverContext) { 126 this.receiverContexts.add(receiverContext); 127 } {code} I think this "java.lang.ArrayIndexOutOfBoundsException: 0" will happen in the following scenario: # receiverContexts.size() = 0 at the line 111 xaResources is created with new XAResource\[0\] # receiverRegistered method is called from other thread between the line 111 and 112 Now receiverContexts.size() = 1 # As receiverContexts.size() = 1, for-loop is executed Then "xaResources\[0\] = ..." will get ArrayIndexOutOfBoundsException at the line 114 because xaResources is empty array.
    via by Masafumi Miura,
  • https://bugzilla.redhat.com/show_bug.cgi?id=1035216 is also reproducible in wildfly. {code} WARN [com.arjuna.ats.jta] (Periodic Recovery) ARJUNA016009: Caught:: java.lang.ArrayIndexOutOfBoundsException: 0 at org.jboss.as.ejb3.remote.EJBTransactionRecoveryService.getXAResources(EJBTransactionRecoveryService.java:114) at com.arjuna.ats.internal.jbossatx.jta.XAResourceRecoveryHelperWrapper.getXAResources(XAResourceRecoveryHelperWrapper.java:51) [narayana-jts-integration-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:516) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkFirstPass(XARecoveryModule.java:182) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:743) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371) [narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] {code} I think the line 111 "new XAResource\[receiverContexts.size()\]" should be placed inside synchronized block. {code:java|title=ejb3/src/main/java/org/jboss/as/ejb3/remote/EJBTransactionRecoveryService.java} 109 @Override 110 public XAResource[] getXAResources() { 111 final XAResource[] xaResources = new XAResource[receiverContexts.size()]; 112 synchronized (receiverContexts) { 113 for (int i = 0; i < receiverContexts.size(); i++) { 114 xaResources[i] = EJBClientManagedTransactionContext.getEJBXAResourceForRecovery(receiverContexts.get(i), arjunaTxCoreEnvironmentBean.getValue().getNodeIdentifier()); 115 } 116 } 117 return xaResources; 118 } ... 124 @Override 125 public void receiverRegistered(final EJBReceiverContext receiverContext) { 126 this.receiverContexts.add(receiverContext); 127 } {code} I think this "java.lang.ArrayIndexOutOfBoundsException: 0" will happen in the following scenario: # receiverContexts.size() = 0 at the line 111 xaResources is created with new XAResource\[0\] # receiverRegistered method is called from other thread between the line 111 and 112 Now receiverContexts.size() = 1 # As receiverContexts.size() = 1, for-loop is executed Then "xaResources\[0\] = ..." will get ArrayIndexOutOfBoundsException at the line 114 because xaResources is empty array.
    via by Masafumi Miura,
  • 7. Changes in this release
    via by Unknown author,
  • 6.3 Release Notes
    via by Unknown author,
  • 7. Cambios en este lanzamiento
    via by Unknown author,
  • 6.3 Release Notes
    via by Unknown author,
  • Notes de sortie 6.3.0
    via by Unknown author,
    • java.lang.ArrayIndexOutOfBoundsException: 0 at org.jboss.as.ejb3.remote.EJBTransactionRecoveryService.getXAResources(EJBTransactionRecoveryService.java:114) at com.arjuna.ats.internal.jbossatx.jta.XAResourceRecoveryHelperWrapper.getXAResources(XAResourceRecoveryHelperWrapper.java:51)[narayana-jts-integration-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.resourceInitiatedRecoveryForRecoveryHelpers(XARecoveryModule.java:516)[narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule.periodicWorkFirstPass(XARecoveryModule.java:182)[narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.doWorkInternal(PeriodicRecovery.java:743)[narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)] at com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery.run(PeriodicRecovery.java:371)[narayana-jts-jacorb-5.0.0.Final.jar:5.0.0.Final (revision: 9aa71)]
    No Bugmate found.