Home Forums DITA and XMetaL Discussion [java] Exception in thread "main" java.lang.StackOverflowError Reply To: [java] Exception in thread "main" java.lang.StackOverflowError

Derek Read

Reply to: [java] Exception in thread "main" java.lang.StackOverflowError

Looks like I can reproduce this issue with an unmodified deliverable “XMetaL Enhanced PDF via RenderX XEP” and a very large CALS table.

From what I can tell (or actually, what I suspect is that) the DITA OT is causing Java to perform some highly recursive operation when it is converting the CALS table format to XSL-FO (used to generate the PDF). Java running on Windows has a specific default stack size (which I think is 64k) and that is being exceeded, causing it to raise this error. With Java all memory must be allocated before it starts doing anything and it is specifically designed not to dynamically allocate more as needed (unlike most software). When it runs out of memory it is designed to stop and complain about it.

I'm not sure what would need to be done to the DITA OT code itself to resolve this or if that it even makes sense to try in this particular case, so the easiest solution is to tell Java to set aside more memory for its stack.

When running the DITA OT at the command line you would simply pass the following additional parameter in:

or some other value higher than the default 64k, you also might get away with 128k, 256k, 512k, etc…

This need was not anticipated and so XMetaL Author Enterprise (all versions) doesn't offer a way to pass this in through its UI. You will need to make a change your installation to enable that. I've asked that we add this to the next release.

In the meantime, for XMetaL Author Enterprise 10, you can make the following changes:

1. Unzip the file I'm attaching and copy the build.xml it contains over the following file:
2. Launch XMetaL Author Enterprise 10.
3. From the Tools menu select Configure Output…
4. In the Configure Output dialog select the Advanced tab.
5. In the “Other output parameters” section add the following setting:
ANT_PARAM_args.xmfo.java_vmarg  =  -Xms1024m -Xmx1024m -Xss1024k

The value 1024k is enough to get the DITA OT producing output for my test table containing 800 rows and 2 columns. If you still get a StackOverflowError after making this change you will need to increase that value.

This build.xml file has not been tested with any versions of XMetaL Author Enterprise other than version 10. If anyone runs into similar issues with an older release I would first recommend upgrading to the current release if possible. If not possible, diff this file against what you have installed to see if you can make a similar change in your version, but keep in mind that if there are other differences in unrelated code those could cause other issues for your version.

External References: