Laurent
Laurent

Reputation: 14401

com.ctc.wstx.exc.WstxParsingException: Text size limit

I am sending a big attachment to a CXF webservice and I get the following exception:

Caused by: javax.xml.bind.UnmarshalException - with linked exception: [com.ctc.wstx.exc.WstxParsingException: Text size limit (134217728) exceeded at [row,col {unknown-source}]: [1,134855131]] at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:426) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362) at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:339) at org.apache.cxf.jaxb.JAXBEncoderDecoder.doUnmarshal(JAXBEncoderDecoder.java:769) at org.apache.cxf.jaxb.JAXBEncoderDecoder.access$100(JAXBEncoderDecoder.java:94) at org.apache.cxf.jaxb.JAXBEncoderDecoder$1.run(JAXBEncoderDecoder.java:797) at java.security.AccessController.doPrivileged(Native Method) at org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:795) ... 25 more

The issue seems to come from the Woodstox library that says

Text size limit (134217728) exceeded

Does someone know if it is possible to increase this limit? if yes, how to do?

Upvotes: 5

Views: 8204

Answers (2)

Tomasz
Tomasz

Reputation: 1416

Following article https://help.salesforce.com/s/articleView?id=001123624&type=1 you need to set properties to value 268435456 = 256MB :

org.apache.cxf.stax.maxTextLength=268435456
com.ctc.wstx.maxTextLength=268435456

Upvotes: 0

Daniel Kulp
Daniel Kulp

Reputation: 14607

If it's coming from woodstox like that, then you aren't sending it as an MTOM attachment. My first suggestion would be to flip it to MTOM so it can be handled outside the XML parsing. Much more efficient as we can keep it as an inputstream or similar and not have it in memory.

If you want to keep it in the XML, you can set the property: "org.apache.cxf.stax.maxTextLength" to some larger value. Keep in mind, stuff coming in from the stax parser like this are held in memory as either a String or byte[] and will thus consume memory.

Upvotes: 6

Related Questions