File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes java.lang.ArrayIndexOutOfBoundsException while marshalling with JAXB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "java.lang.ArrayIndexOutOfBoundsException while marshalling with JAXB" Watch "java.lang.ArrayIndexOutOfBoundsException while marshalling with JAXB" New topic

java.lang.ArrayIndexOutOfBoundsException while marshalling with JAXB

John Foley

Joined: Oct 26, 2009
Posts: 7
We just started seeing this exception crop up in our production environment.

I've been searching and I have not been able to find a whole lot of information on this error. Can anyone shed some light as to what could be causing this and if possible any steps to correct it?

at com.sun.xml.internal.bind.v2.util.CollisionCheckStack.pushNocheck(
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(
at com.sbc.cctp.easl.crm.jaxb.CrmEaslJaxbUtil.javaObject2Xml(
at com.sbc.cctp.easl.crm.jaxb.EaslCreateCaseImpl.generateCreateCaseRequestXML(
at com.sbc.cctp.easl.crm.jaxb.EaslCreateCaseImpl.generateCreateCaseRequestWebServiceXML(
at com.sbc.cctp.easl.dao.adapter.ClarifyJmsAdapter.buildCreateCaseRequestXmlMessage(
at com.sbc.cctp.easl.dao.adapter.ClarifyJmsAdapter.invoke(
at com.sbc.cctp.easl.dao.adapter.AbstractAdapterDispatch.dispatchAdapter(

the method call

the getMarshaller() method
Paul Clapham

Joined: Oct 14, 2005
Posts: 18898

My guess: a race condition which occurs when two threads try to do marshalling at the same time.

True, the code you posted looks like it should be thread-safe. But it's possible that it's running into non-thread-safe situations deep down in the system code which you see at the top of your stack trace.

Or perhaps "JAXBContext.newInstance(CRM_TYPE)" isn't a thread-safe operation and it can return the same object to two different threads. Problems with that theory: I don't know whether that would matter, and the API documentation doesn't mention that as a problem.

Unfortunately that's just speculation, and it isn't clear what you could do to fix it, or how to test that the fix worked. Perhaps somebody else will have a more useful answer...
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 541
I concur in view of

If you are using schema compilation to establish the (pojo) object graph, you should be aware that there is a switch to make out synchronized methods, namely, adding the switch:

The effect of which is basically making all the accessors synchronized (by adding the keyword synchronized to their declaration).

In the meantime as a stop-gap measure, maybe you could try add a lock see if it could achieve the desired effect without making a full analysis?
John Foley

Joined: Oct 26, 2009
Posts: 7
Thank you for replying. I'll implement this and see how it does.
I agree. Here's the link:
subject: java.lang.ArrayIndexOutOfBoundsException while marshalling with JAXB