JIT Issue on IBM Websphere Application Server

Hi
Thank you for additional information. We will further investigate the issue and provide you more information.
Best regards.

Hi Rachel,
As for your code, I see Aspose.Cells used only for reading of field names/values and doesn’t used for reading/writing of images. So you can’t facing this issue in Aspose.Cells anywhereJ
I see also that the picture in the template doc is in Windows Metafile wmf format. By default Aspose.Words converts it to png when saving the doc. Image conversion is very resource angry task and very often additional threads are instantiated for launching such a task. Probably IBM’s JVM optimizes such tasks little more aggressively than Sun’s one so we get corrupted image files on AIX/Websphere as a result.
Aspose.Words has SaveOptions that instruct to preserve metafiles as is when saving a document to html. But we haven’t such an option for other save formats. I will register a request for such feature for other formats.
As for workaround you can convert your image to png or jpeg format. I attached your template corrected so it is png image instead of wmf. Please, try this new template doc.
Let’s also simplifying our test bed so we will test only Aspose.Words + AIX (I just hardcoded field data that you get from cells):

@Test
public void TestMMImagesOnAIX() throws Exception
{
    String template = "\\tmp\\MailMergeWordTemplate2.doc";
    String out = "\\tmp\\MailMerge";
    String[] fieldNames = {"Number1", "Number2", "Number3", "Number4"};
    String[][] fieldvalues = {
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
            {"TRADING CO.", "18501 S. FIGUEROA ST.", "GARDENA ", "SX100 2008"},
    };
    for (int i = 0; i < fieldvalues.length; i++)
    {
        Document doc = new Document(template);
        doc.getMailMerge().execute(fieldNames, fieldvalues[i]);
        String dst = out + i + ".doc";
        doc.save(dst);
    }
}

Best regards,

Hi Konstantin
Thanks for your respose. The code that we had sent shows merging functionality using Aspose-word alone but we are using a similar Aspose-cells merging functionality as well. :slight_smile:
I am still facing the same issue while using the template that you had shared. I aslo tried inserting a .png format image in the word template. The generated document is still corrupted when tested in AIX\Websphere.
Regards
Rachel

Hi
Were you able to reproduce the issue. Please let us know if you need any other additional information to simulate it.
Regards
Rachel

Hi Rachel,
We still can’t reproduce the issue under windows or linux. Probably it is tied with IBM (JIT, Webshpere?) run-time optimization or with your java 2D graphic environment. I have some additional questions for you:

  1. Are you using any java ImageIO plugins, like Sun JAI, for example?
  2. Can you attach the corrupted document and specify: every out document corrupted or only some of them?
  3. Are you tried my simplified test method?
  4. Can you please launch the test with only one out doc?
    Regards,

Yet another request. Can you run the test with disabled JIT optimization on your AIX JVM?
Regards,

Hi Konstantin
Here are some of the information that you had asked for.

  1. We are not using java ImageIO plugins
  2. I used the template that you had shared. The first four documents got generated properly but the remaining 6 were corrupted. (I have attached the template used and the test result docs).
  3. I tried using the test method that you had shared. I tested it as a standalone java class (using IBM Websphere’s JRE)
  4. When I tried using one out doc it got generated properly.
    Currently i’m unable to test disabling JIT but will update you on that once i do it.
    Thanks.

Hi
When I tried with another template(MailMergeWordTemplate3.doc) with a .png format image in it. All of the generated documents were corrupted. Please find the document and the test results attached. In this case, request with single out doc was also corrupted.
Thanks.

Hi Konstantin
As per our implementation standards we are not allowed to disable JIT. Could you please give us other possible solution or some workaround, as this issue is of high priority.We are using the licensed version of Aspose words. Do we have any other means to contact the support team directly.
Thanks

Hi Rachel,
Sorry for delay. I dived in your corrupted docs. They are really interesting.
For the clarity: the Word binary format is organized like the DOS FAT file system (remember it?). So what I see inside your files:

  1. The first corrupted files (TestResult) have corrupted FAT table (only few bytes) but all other things: header, internal streams (including pictures) – all are safe.
  2. AnotherTestResult have corrupted FAT table in the same place plus two corrupted bytes in a “harmless” place. All other things are safe.
  3. Non-corrupted TestResult files – corrupted tooJ almost in the same “harmless” place as AnotherTestResult files.
    I can’t reproduce the issue and I still can’t “visually” find the reason. Images probably don’t responsible for the corruption: all image streams are safe and fat entries for images too. Moreover, I think you can get corrupted files without images as well.
    Please, try to save your output docs to other formats: docx and html. Aspose.Words uses another IO classes to save to these formats. For doing this you just have to change output file extension to “docx” and “html”. And please, post here the result – it will be interesting to look at them.
    Regards,

Hi Konstantin
Thanks for your response.
I carried out the below tests.

  1. Test result for .docx format - All of them are created successfully.
  2. Test result for .html format - All of them are created successfully.
  3. Test result for .doc format with image - Few are created successfully and others are corrupted.
  4. Test result for .doc format without image - All of them are created successfully. None of them are corrupted.
    I am unable to attach the test results now.Will do it as soon as possible.
    Regards
    Rachel

Hi Rachel,
Thanks for the info.
IMO you can get corrupted text-only .doc if it will be big enough – at least as big as corrupted docs with images. Or maybe your .doc files w/o images corrupted as well but in “lucky” places that doesn’t cause any Word failure.
Anyway please send me all your test results. It will be interesting to look at non-.doc files and docs without images. This will help me to find the key.
As I wrote, Aspose.Words for Java uses different IO classes for saving .doc and non-.doc documents. May be AIX JVM contains some specific bug (or feature:) in classes used for .doc saving. In that case I will make a workaround for you.
And sorry that I can’t reproduce your issue at my side: I haven’t AIX and any IBM hardware at hand, except of old good ThinkPadJ
Regards,

Hi Konstantin
Thanks for the response.
I tried using .doc files with size more than the corrupted docs with images. They are also getting generated successfully.
I have attached all the test results for your reference.

Hi Rachel,

Thanks for the test files. Docx and Html files are clean.
Please try another Document.save() overload that uses the same IO classes that DOCX and HTML save() use:

FileOutputStream dstStream = new FileOutputStream(dstName);
doc.save(dstStream, SaveFormat.DOC);
dstStream.close();

If it works I will fix the overload with file name.
Regards,

Hi Konstantin
We tried it but the documents are still getting corrupted. Please find the test results and template attached.
Regards
Rachel

Hi Rachel,

Thanks for the info. The simple way doesn’t work…
I have emailed to you the Aspose.Words jar with some logging logics inside. Please check your mailbox.
This jar simply outputs to console some info about internal doc structure. Please, run your main test (.doc with images aka TestResult) using this jar, collect the output from console and send it here.
Sorry for inconvenience,

Hi Konstantin
I did not recieve the mail that you had sent due to restriction in the security policy. I have mailed you with other option to send me the jar file. Please check your mail for the deatils and let me know once you send it. I will run and share the logs with you.
Thanks
Rachel

Hi Rachel,

I have forwarded the mail to your gmail box as soon as received your reply from corporate email (about ten hours ago). Please check your gmail mailbox.
Regards,

Hi Konstantin,
The jar that you have shared is Aspose-words for jdk1.5. Please share the jdk1.4 version to the same email id.
Regards
Rachel

Hi Konstantin
Thanks. I have run the test code using the jar that you had shared. Please refer to the attached log file and test results.
Regards
Rachel