wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes ArrayIndexOutOfBounds -1 error during unmarshalling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "ArrayIndexOutOfBounds -1 error during unmarshalling" Watch "ArrayIndexOutOfBounds -1 error during unmarshalling" New topic
Author

ArrayIndexOutOfBounds -1 error during unmarshalling

Prag nesh
Greenhorn

Joined: May 21, 2013
Posts: 3
Hi All,

We use JAXB marshalling and unmarshalling in our application. We have suddenly started getting an ArrayIndexOutOBounds Exception. Below is the stacktrace


We use java 1.5.0_19. Can anyone help in identifying the root cause for this?
Please tell me if you need more info
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

When using your marshaller, try setting the com.sun.xml.bind.objectIdentitityCycleDetection property to false:
Prag nesh
Greenhorn

Joined: May 21, 2013
Posts: 3
Hi James,

Thanks for the response. May I request you to please give more details on how this will help eliminate the problem. I will try searching for details about this property but an explanation from an experienced guy like you will be much better
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

Prag

I think I may have encountered this problem on a previous project.

I found this article too which describes a similar problem: https://www.java.net//node/661561

The important post from the article states:

Okay, I found this in the source and documentation.

com.sun.xml.bind.objectIdentitityCycleDetection and set it to false on the Marshaller

While this does solve my problem it would seem that the aforementioned code is a bug since one can never have a negative array index position. Additionally, the useIdentity flag just appears to either use absolute values or not.

Here's the hash method from the CollisionCheckStack class:

private int hash(Object o) {
if (useIdentity)
return System.identityHashCode(o) % initialHash.length;
else
return Math.abs(o.hashCode() % initialHash.length);
}


The hash returned here is used to access an array element. If useIdentity is true, the generated hash could be negative, hence the ArrayIndexOutOfBoundsException.

Also, refer to this regarding JAXB properties: https://jaxb.java.net/nonav/2.1.1/docs/vendorProperties.html#identityCycleCheck

Setting useIdentity to false is achieved by setting the com.sun.xml.bind.objectIdentitityCycleDetection property to false.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayIndexOutOfBounds -1 error during unmarshalling