• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

ArrayIndexOutOfBounds -1 error during unmarshalling

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1051
5
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic