users@jaxb.java.net

Threading issue with big instance documents

From: Marc Giger <gigerstyle_at_gmx.ch>
Date: Mon, 16 Jul 2007 14:45:09 +0200

Hi all,

I read all the faq's and searched in the archives but found no explanation to my problem.

I have a Webservice with validating JAXB Binding. In this webservice the instancedocument will be processed with multiple xslt _in parallel_. Every xslt process results in a different output document.

If I invoke the service with big documents (e.g 24 MBytes) some of the transformations fail with a error msg like the
following:

SystemId Unknown; Line #149; Column #105; Illegal value used for
attribute name:
SystemId Unknown; Line #149; Column #105; Illegal value used for
attribute name:

After some debugging I saw that the document contains some garbage elements like:
<testCase1testCase2>...</testCase1testCase2>

instead of
<testCase1>...</testCase1>
<testCase2>...</testCase2>

The transformation is done the following way:

JAXBContext jaxbContext = JAXBContext.newInstance("....");

JAXBElement<MyInputType> myInputTypeElement = ..."instancedocument from service method"....;
JAXBSource source = new JAXBSource(jaxbContext, myInputTypeElement);

Transformer transformer = template.newTransformer();
JAXBResult result = new JAXBResult(jaxbContext);
transformer.transform(source, result);

(JAXBElement<MyOutputType>)result.getResult();

The JAXBContext is just once instanciated as documented in the faqs and docs. I did also test it with a new instance for
every use but without success.

When the xsl transformations are done serial all is working fine.
The problem does mostly occur if tomcat is started freshly. If the classes are hot the problem doesn't occur always.

My workaround for the problem is atm that I marshall the whole document to a ByteArrayOutputStream and unmarshall it from there so that every thread has a new instance.

This problem occurs with JAXB 2.0.5 and 2.1.4

Has somebody an explanation?

Thanks for the help

Marc