File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayIndexOutOfBounds -1 error during unmarshalling

 
Prag nesh
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When using your marshaller, try setting the com.sun.xml.bind.objectIdentitityCycleDetection property to false:
 
Prag nesh
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic