|
Replies:
11
-
Last Post:
Jun 6, 2008 6:58 AM
by: sehgal_gurpreet
|
|
|
|
|
|
|
ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 4, 2007 7:16 AM
|
|
|
We are desperately trying to deploy an application that leverages JAXB 2.1. The application works fine locally and we continue to try to get it working on the development server.
The latest issue we receive is an ArrayIndexOutOfBoundsException when Serializing. Deserializing works fine.
The offending line of code appears to be the first line of the findDuplicate method in CollisionCheckStack:
private boolean findDuplicate(E o, int hash) { int p = initialHash[hash];
Here's the stack trace.
Caused by: java.lang.ArrayIndexOutOfBoundsException at java.lang.Throwable.<init>(Throwable.java:181) at java.lang.Exception.<init>(Exception.java:29) at java.lang.RuntimeException.<init>(RuntimeException.java:32) at java.lang.IndexOutOfBoundsException.<init>(IndexOutOfBoundsException.java:27) at java.lang.ArrayIndexOutOfBoundsException.<init>(ArrayIndexOutOfBoundsException.java:26) at com.sun.xml.bind.v2.util.CollisionCheckStack.findDuplicate(CollisionCheckStack.java:133) at com.sun.xml.bind.v2.util.CollisionCheckStack.push(CollisionCheckStack.java:71) at com.sun.xml.bind.v2.runtime.XMLSerializer.pushObject(XMLSerializer.java:494) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:609) at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:113) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:286) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:663) at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:113) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:286) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:571) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:276) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:472) at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:301) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:230) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:75) at org.codehaus.xfire.jaxb2.JaxbType.writeObject(JaxbType.java:107) at org.codehaus.xfire.aegis.AegisBindingProvider.writeParameter(AegisBindingProvider.java:194) at org.codehaus.xfire.service.binding.AbstractBinding.writeParameter(AbstractBinding.java:275) at org.codehaus.xfire.service.binding.DocumentBinding.writeMessage(DocumentBinding.java:65) at org.codehaus.xfire.soap.SoapSerializer.writeMessage(SoapSerializer.java:80) at org.codehaus.xfire.transport.http.HttpChannel.writeWithoutAttachments(HttpChannel.java:56) at org.codehaus.xfire.transport.http.XFireServletChannel.sendViaServlet(XFireServletChannel.java:84) at org.codehaus.xfire.transport.http.XFireServletChannel.send(XFireServletChannel.java:43) at org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26) at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:130) at org.codehaus.xfire.service.binding.ServiceInvocationHandler.sendMessage(ServiceInvocationHandler.java:285) ... 33 more
I'll try to setup remote debugging since the problem doesn't occur locally and see what I can find. In the meantime if any ideas come to mind as to the cause or solution please respond with them.
Thanks in advance,
Mark
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 4, 2007 8:40 AM
in response to: mspitzer
|
|
|
Okay, I was able to find out more while remotely debugging.
A negative hashcode gets used and that value is used as an array index. Apparently, there is a boolean called useIdentity that if set to true can allow negative numbers and if set to false while take the absolute value.
Still researching how to make that boolean value false.
|
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 4, 2007 11:18 AM
in response to: mspitzer
|
|
|
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); }
|
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 9, 2007 3:22 PM
in response to: mspitzer
|
|
|
Thanks. I just committed a fix in 2.1.
|
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 23, 2007 12:03 PM
in response to: kohsuke
|
|
|
Did this make it into the 2.1.1 release? I was looking at the source from that release and I don't immediately see changes in the problem areas.
|
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 23, 2007 12:48 PM
in response to: mspitzer
|
|
|
It should be. CollisionCheckStack now reads:
private int hash(Object o) {
return ((useIdentity?System.identityHashCode(o):o.hashCode())&0x7FFFFFFF) % initialHash.length;
}
... which handles negative hash code, right?
|
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 23, 2007 12:56 PM
in response to: kohsuke
|
|
|
You are correct sir. I thought I had attached the new source to my binaries for viewing in my IDE but apparently it was still showing the source from the December 06 release. My bad.
Thanks,
Mark
|
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 25, 2007 10:05 AM
in response to: mspitzer
|
|
|
Good. Thanks for checking.
|
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 31, 2008 8:12 AM
in response to: mspitzer
|
|
|
Hi,
I have an error which is very similar to the one described in this thread. I thought that updating my JDK to the update 4 and therefore, using JAXB2.1.1, I will be able to solve my problem but no success.
Yesterday I post a comment in Rama Pulavathi's weblog (http://weblogs.java.net/blog/ramapulavarthi/archive/2008/01/jaxws_21_and_ja.html) related to using latest version of JAXB under JDK6U4 and he suggested me to to put the stack trace in the Metro Forums (I hope here is the right place!).
The error description is that, randomly, when calling to marshal method with valid arguments, a NullPointerException and/or ArrayIndexOutOfBoundsException appears.
In our application, we have a class hierarchy to model all kinds of events that may occur during execution. For each event we create (classes have necessary xml annotations) a XML entry to generate an activity report. This works fine, but, as stated, randomly we get those exceptions and from this moment on, no XML is longer generated (the exception jumps continuously). I think that it may be a bug because for a given event (object with all values not null) the XML marshalling works OK but sometimes the same event causes the exception.
A curious thing is that the stack trace does not have always the same line for the JAXB classes. Well, I paste two stack traces:
Exception in thread "Thread-1" java.lang.NullPointerException com.sun.xml.internal.bind.v2.runtime.Coordinator.popCoordinator(Coordinator.java:121) com.sun.xml.internal.bind.v2.runtime.XMLSerializer.close(XMLSerializer.java:779) com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:301) com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221) javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:77) testool.TestEngine.Report.ReportWriter.eventXMLformatted(ReportWriter.java:269) testool.TestEngine.EventManagement.TestToolEventProcessorTargetsXML.run(TestToolEventProcessorTargetsXML.java:95)
Exception in thread "Thread-17" java.lang.ArrayIndexOutOfBoundsException: -1 com.sun.xml.internal.bind.v2.util.CollisionCheckStack.pushNocheck(CollisionCheckStack.java:67) com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:454) com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:292) com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221) javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:77) testool.TestEngine.Report.ReportWriter.eventXMLformatted(ReportWriter.java:269) testool.TestEngine.EventManagement.TestToolEventProcessorTargetsXML.run(TestToolEventProcessorTargetsXML.java:95
*************************** Another one
Exception in thread "Thread-478" java.lang.NullPointerException com.sun.xml.bind.v2.runtime.Coordinator.popCoordinator(Coordinator.java:158) com.sun.xml.bind.v2.runtime.XMLSerializer.close(XMLSerializer.java:841) com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:337) com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257) javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96) testool.TestEngine.Report.ReportWriter.eventXMLformatted(ReportWriter.java:276) testool.TestEngine.EventManagement.TestToolEventProcessorTargetsXML.run(TestToolEventProcessorTargetsXML.java:95)
Exception in thread "Thread-486" java.lang.ArrayIndexOutOfBoundsException: -1 com.sun.xml.bind.v2.util.CollisionCheckStack.pushNocheck(CollisionCheckStack.java:121) com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:483) com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328) com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257) javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96) testool.TestEngine.Report.ReportWriter.eventXMLformatted(ReportWriter.java:276) testool.TestEngine.EventManagement.TestToolEventProcessorTargetsXML.run(TestToolEventProcessorTargetsXML.java:95)
Since I did not solve the error (with JDK6U4) I downloaded JAXB2.1.6 and read in Rama Pulavarthi's weblog that currently it is not necessary to use the endorsed mechanism, only to put the .jar files of the new release in the classpath.
I've questions: Is it necessary to put any .jar file in jdk/jre/lib/endorsed (such as jaxb-xjc) to use JAXB2.1.6 with JDK6U4? (I want to use JAXB2.1.6 because the release JAXB2.1.1 that is supposed to be included in JDK6U4 seems to don't work or I'm doing something wrong).
I'm a bit lost because I don't know if the exception I get is the same of this post or not, and neither If being the same, I'm using correctly the release where solved (JAXB2.1.1) or if I'm using correctly the JAXB2.1.6.
As suggested by Rama, in parallel, I'm going to try your which4j tool in order to know the correct classes I'm loading. Now, I start my application using a sh script like this (the script and all jar files are in the same folder):
export CLASSPATH=$CLASSPATH:MYJAR.jar:activation.jar:jaxb-api.jar:jaxb-impl.jar:jsr173_1.0_api.jar java -Djava.security.policy=MYPOLICY -Djava.library.path=AN_ASN_WRAPPER_IN_C -jar MYJAR.jar
This application uses RMI to receive events from other applications.
As I said above, everything works fine BUT randomly I get the exception.
Any idea?
|
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jan 31, 2008 4:03 PM
in response to: frodero
|
|
|
Can you see this thread also
http://forums.java.net/jive/thread.jspa?messageID=214052𴐤
Jitu
metro@javadesktop.org wrote: > Hi, > > I have an error which is very similar to the one described in this thread. I thought that updating my JDK to the update 4 and therefore, using JAXB2.1.1, I will be able to solve my problem but no success. > > Yesterday I post a comment in Rama Pulavathi's weblog (http://weblogs.java.net/blog/ramapulavarthi/archive/2008/01/jaxws_21_and_ja.html) related to using latest version of JAXB under JDK6U4 and he suggested me to to put the stack trace in the Metro Forums (I hope here is the right place!). > > The error description is that, randomly, when calling to marshal method with valid arguments, a NullPointerException and/or ArrayIndexOutOfBoundsException appears. > > In our application, we have a class hierarchy to model all kinds of events that may occur during execution. For each event we create (classes have necessary xml annotations) a XML entry to generate an activity report. This works fine, but, as stated, randomly we get those exceptions and from this moment on, no XML is longer generated (the exception jumps continuously). I think that it may be a bug because for a given event (object with all values not null) the XML marshalling works OK but sometimes the same event causes the exception. > > A curious thing is that the stack trace does not have always the same line for the JAXB classes. Well, I paste two stack traces: > > Exception in thread "Thread-1" java.lang.NullPointerException > com.sun.xml.internal.bind.v2.runtime.Coordinator.popCoordinator(Coordinator.java:121) > com.sun.xml.internal.bind.v2.runtime.XMLSerializer.close(XMLSerializer.java:779) > com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:301) > com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221) > javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:77) > testool.TestEngine.Report.ReportWriter.eventXMLformatted(ReportWriter.java:269) > testool.TestEngine.EventManagement.TestToolEventProcessorTargetsXML.run(TestToolEventProcessorTargetsXML.java:95) > > Exception in thread "Thread-17" java.lang.ArrayIndexOutOfBoundsException: -1 > com.sun.xml.internal.bind.v2.util.CollisionCheckStack.pushNocheck(CollisionCheckStack.java:67) > com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:454) > com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:292) > com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:221) > javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:77) > testool.TestEngine.Report.ReportWriter.eventXMLformatted(ReportWriter.java:269) > testool.TestEngine.EventManagement.TestToolEventProcessorTargetsXML.run(TestToolEventProcessorTargetsXML.java:95 > > *************************** Another one > > Exception in thread "Thread-478" java.lang.NullPointerException > com.sun.xml.bind.v2.runtime.Coordinator.popCoordinator(Coordinator.java:158) > com.sun.xml.bind.v2.runtime.XMLSerializer.close(XMLSerializer.java:841) > com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:337) > com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257) > javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96) > testool.TestEngine.Report.ReportWriter.eventXMLformatted(ReportWriter.java:276) > testool.TestEngine.EventManagement.TestToolEventProcessorTargetsXML.run(TestToolEventProcessorTargetsXML.java:95) > > Exception in thread "Thread-486" java.lang.ArrayIndexOutOfBoundsException: -1 > com.sun.xml.bind.v2.util.CollisionCheckStack.pushNocheck(CollisionCheckStack.java:121) > com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:483) > com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328) > com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:257) > javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:96) > testool.TestEngine.Report.ReportWriter.eventXMLformatted(ReportWriter.java:276) > testool.TestEngine.EventManagement.TestToolEventProcessorTargetsXML.run(TestToolEventProcessorTargetsXML.java:95) > > Since I did not solve the error (with JDK6U4) I downloaded JAXB2.1.6 and read in Rama Pulavarthi's weblog that currently it is not necessary to use the endorsed mechanism, only to put the .jar files of the new release in the classpath. > > I've questions: Is it necessary to put any .jar file in jdk/jre/lib/endorsed (such as jaxb-xjc) to use JAXB2.1.6 with JDK6U4? (I want to use JAXB2.1.6 because the release JAXB2.1.1 that is supposed to be included in JDK6U4 seems to don't work or I'm doing something wrong). > > I'm a bit lost because I don't know if the exception I get is the same of this post or not, and neither If being the same, I'm using correctly the release where solved (JAXB2.1.1) or if I'm using correctly the JAXB2.1.6. > > As suggested by Rama, in parallel, I'm going to try your which4j tool in order to know the correct classes I'm loading. Now, I start my application using a sh script like this (the script and all jar files are in the same folder): > > export CLASSPATH=$CLASSPATH:MYJAR.jar:activation.jar:jaxb-api.jar:jaxb-impl.jar:jsr173_1.0_api.jar > java -Djava.security.policy=MYPOLICY -Djava.library.path=AN_ASN_WRAPPER_IN_C -jar MYJAR.jar > > This application uses RMI to receive events from other applications. > > As I said above, everything works fine BUT randomly I get the exception. > > Any idea? > [Message sent by forum member 'frodero' (frodero)] > > http://forums.java.net/jive/thread.jspa?messageID=256802 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net > For additional commands, e-mail: users-help@metro.dev.java.net > >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net For additional commands, e-mail: users-help@metro.dev.java.net
|
|
|
|
|
|
|
|
|
|
Re: ArrayIndexOutOfBoundsException on Serialization using JAXB 2.1
Posted:
Jun 6, 2008 6:58 AM
in response to: mspitzer
|
|
|
I am using JAXB2.1 and application is working on local m/c without any issue. When I deployed application on linux system I got below exception
java.lang.ArrayIndexOutOfBoundsException at java.lang.Throwable.<init>(Throwable.java:181) at java.lang.Exception.<init>(Exception.java:29) at java.lang.RuntimeException.<init>(RuntimeException.java:32) at java.lang.IndexOutOfBoundsException.<init>(IndexOutOfBoundsExcepti on.java:27) at java.lang.ArrayIndexOutOfBoundsException.<init>(ArrayIndexOutOfBou ndsException.java:26) at com.sun.xml.bind.v2.util.CollisionCheckStack.findDuplicate(Collisi onCheckStack.java:112) at com.sun.xml.bind.v2.util.CollisionCheckStack.push(CollisionCheckSt ack.java:53) at com.sun.xml.bind.v2.runtime.XMLSerializer.pushObject(XMLSerializer .java:471) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerial izer.java:574) at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.ser ializeBody(SingleElementNodeProperty.java:113) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassB eanInfoImpl.java:286) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:532) at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassB eanInfoImpl.java:276) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerialize r.java:461) at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.ja va:292) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl. java:221) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMars hallerImpl.java:70) at com.penske.apps.hvut.util.JAXBUtil.marshall(JAXBUtil.java:67) at com.penske.apps.hvut.business.HVUTBusiness.marshallXML(HVUTBusines s.java:747) at com.penske.apps.hvut.business.HVUTBusiness.generateTransmissionFil e(HVUTBusiness.java:299) at com.penske.apps.hvut.application.RequestProcessor.main(RequestProc essor.java:47) java.lang.Exception:
The line has the issue is: m.marshal(objReturn, new FileOutputStream(new File(location)))
Thanks
|
|
|
|
|