File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
Author

java.lang.ArrayIndexOutOfBoundsException while marshalling with JAXB

John Foley
Greenhorn

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?

java.lang.ArrayIndexOutOfBoundsException
at com.sun.xml.internal.bind.v2.util.CollisionCheckStack.pushNocheck(CollisionCheckStack.java:110)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:475)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:314)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:243)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:87)
at com.ibm.xml.xlxp2.jaxb.marshal.MarshallerProxy.marshal(MarshallerProxy.java:100)
at com.sbc.cctp.easl.crm.jaxb.CrmEaslJaxbUtil.javaObject2Xml(CrmEaslJaxbUtil.java:116)
at com.sbc.cctp.easl.crm.jaxb.EaslCreateCaseImpl.generateCreateCaseRequestXML(EaslCreateCaseImpl.java:71)
at com.sbc.cctp.easl.crm.jaxb.EaslCreateCaseImpl.generateCreateCaseRequestWebServiceXML(EaslCreateCaseImpl.java:48)
at com.sbc.cctp.easl.dao.adapter.ClarifyJmsAdapter.buildCreateCaseRequestXmlMessage(ClarifyJmsAdapter.java:399)
at com.sbc.cctp.easl.dao.adapter.ClarifyJmsAdapter.invoke(ClarifyJmsAdapter.java:113)
at com.sbc.cctp.easl.dao.adapter.AbstractAdapterDispatch.dispatchAdapter(AbstractAdapterDispatch.java:106)
at com.sbc.cctp.easl.dao.work.AdapterDispatchWorkManager.invoke(AdapterDispatchWorkManager.java:24)
at com.sbc.cctp.easl.dao.work.WorkImpl.run(WorkImpl.java:117)
at com.ibm.ws.asynchbeans.J2EEContext.run(J2EEContext.java:782)
at com.ibm.ws.asynchbeans.WorkWithExecutionContextImpl.go(WorkWithExecutionContextImpl.java:222)
at com.ibm.ws.asynchbeans.ABWorkItemImpl.run(ABWorkItemImpl.java:159)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1563)

the method call


the getMarshaller() method
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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: 499
    
    3
I concur in view of
at com.ibm.ws.asynchbeans.ABWorkItemImpl.run(ABWorkItemImpl.java:159)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1563)


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:
-Xsync-methods

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
Greenhorn

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: http://aspose.com/file-tools
 
subject: java.lang.ArrayIndexOutOfBoundsException while marshalling with JAXB
 
Similar Threads
Wanted: Help serializing Generic Maps!
Session Size
java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion
Getting Error while preparing XML
JAXB Error