In Mule 3.9.0, while we are trying to convert an object to XML using jaxb, we are getting the below error
Message : null (java.util.ConcurrentModificationException)
Element : /test/processors/0 @ test-masked:masked.xml:685 (JAXB Object to JMSMessage (XML string))
--------------------------------------------------------------------------------
Exception stack is:
null (java.util.ConcurrentModificationException) (org.mule.api.transformer.TransformerException)
java.util.ArrayList$Itr.checkForComodification(ArrayList.java:901)
java.util.ArrayList$Itr.next(ArrayList.java:851)
com.sun.xml.bind.v2.runtime.reflect.Lister$CollectionLister$1.next(Lister.java:284)
com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:135)
com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:155)
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340)
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696)
com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:152)
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340)
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:696)
com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:152)
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:340)
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:593)
com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:324)
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244)
javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:116)
org.mule.module.xml.transformer.jaxb.JAXBMarshallerTransformer.doTransform(JAXBMarshallerTransformer.java:77)
org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:415)
org.mule.transformer.AbstractTransformer.transform(AbstractTransformer.java:366)
(40 more...)
The place where we try to convert is in an asynchronous call as below
<async>
<mulexml:jaxb-object-to-xml-transformer
returnClass="java.lang.String" mimeType="text/xml"
jaxbContext-ref="JAXB_Context_Update_Journey"/>
<logger
message="#[message:correlationId] | pushing to cache.inbox -payload - #[payload]"
level="INFO" category="update cache" />
</async>
Project wants us to stick with community version and hence we can't upgrade to 4 +
With the given situation, how do we resolve this? Without it was working fine. After we changed to asynchronous this issue started. We also upgraded to Mule 3.9.5, but still the same issue.
The exception ConcurrentModificationException and the stacktrace indicates that a list was modified concurrently. It seems that the
asyncthread and the original thread of the flow are using the payload at the same time and that causes the error. You could resolve the issue by creating a clone of the input payload. But that probably will be the same as converting the payload in the original thread anyway.Mule 4 may have better handling of this kind of situations with the feature of targeting operations to variables instead of the payload and isolation, however you would need to migrate your application and see how your use case works there.