Serializing a DOM - Java

Soldato
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
OK this might be lacking in some details, simply because I don't know all of them. I have a DOM in XML format, the length of the String that makes up the DOM is 89,424,168, less than the theoretical limit of the length of a string (2,147,483,647)

This XML is a Jasper report exported to XML format, I am trying to serialize this XML and add it to my response XML (client->server architecture).

The problem is the response XML (which includes the serialized DOM) has been truncated, so the client has issues reading it.

Is there a limit to how much can be serialized? For info serializing is done by a org.apache.xml.serialize.XMLSerializer, it looks like it can throw an IOException which stupidly is being caught but not dealt with! (I didn't write this) I have however added an IOException breakpoint caught and uncaught to Eclipse and that isn't triggered.

EDIT: Ok seems there is a "java.net.SocketException: Broken pipe" when sending the response from the Server, so the client is closing the connection before the server has finished responding!
 
Last edited:
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
As is usually the case, I'm answering my own question! :p

Basically the issue was the client receiving the response read the length of the response from the first 8 bytes, so a maximum of 99,999,999 bytes. The response I was sending was larger than that, up the header size to 9 bytes and the issue goes away.
 
Soldato
OP
Joined
1 Mar 2003
Posts
5,508
Location
Cotham, Bristol
Sorry yeah missing a bit from that explanation, yes it is reading the first 8 bytes, but it's reading it from an InputStream using read(). Which returns an int in the range 0-255, that int is converted to a char representing a digit, so a max of 8 digits.

And yes, yes it was. Lots of serialized XML in the response!

Had to abandon it anyway as it was just causing too much memory to be consumed on the heap when the response was being decoded! A change in architecture would be needed to get it working properly. Perhaps by dividing the response up in to chunks.
 
Back
Top Bottom