Aspose.Words Java on IBM i (AS/400)

Hi,

I’m trialling your software for a customer and have successfully compiled and run my program on a Windows PC running Java 8, however when I run this program on our server, IBM i (AS/400) also running Java 8 I get the following exception:

Exception in thread "main" com.aspose.words.internal.zzXDK: Exception on self test: Array index out of range: 32: EC
at com.aspose.words.internal.zzZDB.zzX54(Unknown Source)
at com.aspose.words.internal.zzWCu.zzX54(Unknown Source)
at com.aspose.words.internal.zzWCu.<clinit>(Unknown Source)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:337)
at com.aspose.words.internal.zzWvt.zzYuZ(Unknown Source)
at com.aspose.words.internal.zzWvt.zzZjd(Unknown Source)
at com.aspose.words.internal.zzWvt$zzX54.run(Unknown Source)
at com.aspose.words.internal.zzWvt.zzWkO(Unknown Source)
at com.aspose.words.internal.zzZ5y$zzY5k.<init>(Unknown Source)
at com.aspose.words.internal.zzZ5y$zzX54.zzX54(Unknown Source)
at com.aspose.words.internal.zzY4x.<clinit>(Unknown Source)
at com.aspose.words.internal.zzZAD.<init>(Unknown Source)
at com.aspose.words.internal.zzZAD.<init>(Unknown Source)
at com.aspose.words.internal.zzZAD.<clinit>(Unknown Source)
at com.aspose.words.zzXgo.<init>(Unknown Source)
at com.aspose.words.zzWjW.zzX54(Unknown Source)
at com.aspose.words.zzWjW.zzX54(Unknown Source)
at com.aspose.words.zzVOD.zzZFw(Unknown Source)
at com.aspose.words.zzZJ1.zzX54(Unknown Source)
at com.aspose.words.zzWjW.zzX54(Unknown Source)
at com.aspose.words.zzVSM.zzX54(Unknown Source)
at com.aspose.words.zzWqO.zzX54(Unknown Source)
at com.aspose.words.zzYqe.zzYel(Unknown Source)
at com.aspose.words.zzXhz.zzX54(Unknown Source)
at com.aspose.words.zzXhz.zzYFZ(Unknown Source)
at com.aspose.words.zzXhz.zzX54(Unknown Source)
at com.aspose.words.zzXhz.zzX54(Unknown Source)
at com.aspose.words.zzXhz.zzYZT(Unknown Source)
at com.aspose.words.zzXhz.zzX54(Unknown Source)
at com.aspose.words.zzXhz.zzX54(Unknown Source)
at com.aspose.words.zzXhz.zzX54(Unknown Source)
at com.aspose.words.zzXhz.zzZaX(Unknown Source)
at com.aspose.words.zzXhz.zzYjj(Unknown Source)
at com.aspose.words.zzXhz.zzre(Unknown Source)
at com.aspose.words.zzYqe.zzXTl(Unknown Source)
at com.aspose.words.zzW6r.zzXTl(Unknown Source)
at com.aspose.words.Document.zzY5k(Unknown Source)
at com.aspose.words.Document.zzX54(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)
at com.aspose.words.Document.<init>(Unknown Source)
at ConvertDOCToPDF.main(ConvertDOCToPDF.java:10)

Is there anything I need to do to get this to run on the server ?

Many thanks,
David.

@daviddow Which version of Aspose.Words do you use? Does the problem occur with all documents or with some particular document only? If the problem occurs with a particular document, please attach it here for testing. Also, please provide a simple code that will allow us to reproduce the problem.

Alexey,

I’m using the latest 23.6 version of Aspose.Words.
This is with all documents, I’ve just been testing with a very basic doucment with one line of text.
Here is my code which works on Windows but not on IBM i:

 import com.aspose.words.Document;
 import com.aspose.words.SaveFormat;
 import java.io.*;
 
 public class ConvertDOCToPDF {
 
 	public static void main(String[] args) {
 
 		try {
 			Document doc = new Document(args[0]);
 			doc.save(args[0]+".pdf",SaveFormat.PDF);  //Save the document in PDF format.
 			doc.save(args[0]+".txt",SaveFormat.TEXT); //Save the document in TXT format.
 		} catch (Exception e) {
 			System.out.println("toString(): " + e.toString());
 			System.out.println("getMessage(): " + e.getMessage());
 			System.out.println("StackTrace: ");
 			e.printStackTrace();
 		}
 
 	}
 
 }

The IBM i is running the following version of Java:

java version “1.8.0_251”
Java™ SE Runtime Environment (build 8.0.6.10 - pap6480sr6fp10-20200408_01(SR6 FP10))
IBM J9 VM (build 2.9, JRE 1.8.0 OS/400 ppc64-64-Bit Compressed References 20200402_443261 (JIT enabled, AOT enabled)
OpenJ9 - 35ef566
OMR - 4bca4f4
IBM - 55acf4a)
JCL - 20200407_01 based on Oracle jdk8u251-b08

Any ideas on how to get this working would be good.

Regards,
David.

@daviddow Thank you for additional information. I will consult with our Java developers and provide you more information.

@daviddow
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSJAVA-2877

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@daviddow, the exception with the “Exception on self test: Array index out of range: 32: EC” message is thrown on IBM J9 VM while applying the license, for example:

License lic = new License();
lic.setLicense("Aspose.Words.Java.lic");

This license issue is reproducible with Aspose.Words 23.6 and 23.7 but not with 23.5. The only change in the 23.6 version that could affect the license code is upgrading the BouncyCastle library to a newer version (1.0.2.4). There were multiple requests from our customers to upgrade BouncyCastle due to CVE-2022-45146 vulnerability issue found in previous versions.

BouncyCastle cryptographic methods are used by Aspose.Words for Java in Aspose license code. So it seems that the BouncyCastle upgrade is the root cause for the license issue as no other changes in the license code were made in Aspose.Words for Java 23.6.

The license issue is not reproducible with other JDKs (OpenJDK, Eclipse OpenJ9). It seems that combination of BouncyCastle 1.0.2.4 and IBM J9 VM leads to the issue.

Could you consider switching to another JDK? Eclipse OpenJ9 might be a candidate as it is a continuation of IBM J9.

Denis,

Thanks for the response, as moving to another JDK on the installed OS version might not be possible I’ve tried using Aspose Words 23.5 and this works fine. As the function locked down and not accessible the weakness in BouncyCastle shouldn’t be a problem.

Regards,
David.

The issues you have found earlier (filed as WORDSJAVA-2877) have been fixed in this Aspose.Words for Java 23.12 update.

The issues you have found earlier (filed as WORDSJAVA-2877) have been fixed in this Aspose.Words for Java 24.4 update.

The issues you have found earlier (filed as WORDSJAVA-2877) have been fixed in this Aspose.Words for Java 24.4 update.

I’m observing the same exception on IBM JDK in combination with 24.7 version

@laurens.makel You should use special Aspose.Words JAR for IBM. Please use jdk17ibm clasifier:

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-words</artifactId>
    <version>24.8</version>
    <classifier>jdk17ibm</classifier>
</dependency>

Thanks, that indeed resolves the initialization error. I’m getting some java2sec exceptions now which I’d have to resolve.

Do you have an overview of required permissions to be added to a policy file?

@laurens.makel,

We don’t have such an overview of the required permissions, so you can allow everything at your own discretion, and please let us know what exceptions you have so we can look into this more closely.

After granting some permissions, the Words library is able to start-up and works as expected. Thank you for the golden tip here!

Here are some permissions that have been granted in the past, im not entirely sure if all listed permissions are still relevant, but the upgrade path we took was 19.1 → 23.1 → 24.7

// required for Aspose-Word
permission com.aspose.words.internal.zzZPE "defaultRandomConfig";
permission com.aspose.words.internal.zzZPE "unapprovedModeEnabled";
permission com.aspose.words.internal.zzZPE "getStackTrace";

// since Aspose 23.1
permission com.aspose.words.internal.zzZ2w "defaultRandomConfig";
permission com.aspose.words.internal.zzZ2w "unapprovedModeEnabled";
permission com.aspose.words.internal.zzZ2w "exportPrivateKey";
permission com.aspose.words.internal.zzZ2w "exportPrivateKey";
permission java.security.SecurityPermission "putProviderProperty.BCFIPS";
permission java.security.SecurityPermission "getProperty.org.bouncycastle.pkcs1.not_strict";
permission java.security.SecurityPermission "getProperty.org.bouncycastle.rsa.allow_multi_use";
permission java.security.SecurityPermission "getProperty.org.bouncycastle.fips.approved_only";
permission java.io.FilePermission "${/}opt{/}data{/}wasap10{/}tmp${/}-", "write";
permission java.io.FilePermission "${/}opt{/}data{/}wasap10{/}tmp", "write";
permission java.io.FilePermission "${/}opt{/}kde3{/}share{/}fonts${/}-", "read";
permission java.io.FilePermission "${/}opt{/}kde3{/}share{/}fonts", "read";
permission java.io.FilePermission "${/}run{/}current-system{/}sw{/}share{/}X11-fonts${/}-", "read";
permission java.io.FilePermission "${/}run{/}current-system{/}sw{/}share{/}X11-fonts", "read";
permission java.io.FilePermission "${/}system{/}fonts${/}-", "read";
permission java.io.FilePermission "${/}system{/}fonts", "read";
permission java.io.FilePermission "${/}QIBM{/}UserData{/}OS400{/}Fonts${/}-", "read";
permission java.io.FilePermission "${/}QIBM{/}UserData{/}OS400{/}Fonts", "read";
permission java.io.FilePermission "${/}etc{/}fonts{/}fonts.conf", "read";
permission java.io.FilePermission "${/}user{/}openwin{/}lib{/}X11{/}fonts${/}-", "read";
permission java.io.FilePermission "${/}user{/}openwin{/}lib{/}X11{/}fonts", "read";
permission java.io.FilePermission "${/}user{/}share{/}X11{/}fonts${/}-", "read";
permission java.io.FilePermission "${/}user{/}share{/}X11{/}fonts", "read";

// since Aspose 24.7
permission java.security.SecurityPermission "getProperty.com.aspose.pdf.internal.ms.core.bc.disabledAlgorithms";
permission java.io.FilePermission "${/}System{/}Library{/}Fonts{/}Supplemental${/}-", "read";
permission java.io.FilePermission "${/}System{/}Library{/}Fonts{/}Supplemental", "read";
permission java.io.FilePermission "/System/Library/Fonts/Supplemental/-", "read";
permission java.io.FilePermission "/System/Library/Fonts/Supplemental", "read";

permission java.io.FilePermission "${/}usr{/}openwin{/}lib{/}X11{/}fonts{/}TrueType{/}-", "read";
permission java.io.FilePermission "${/}usr{/}openwin{/}lib{/}X11{/}fonts{/}TrueType", "read";
permission java.io.FilePermission "/usr/openwin/lib/X11/fonts/TrueType/-", "read";
permission java.io.FilePermission "/usr/openwin/lib/X11/fonts/TrueType", "read";

permission com.aspose.words.internal.zzWtb "defaultRandomConfig";

// required for Aspose libary's fonts
permission java.io.FilePermission "/usr/share/fonts/-", "read";
permission java.io.FilePermission "/usr/share/fonts", "read";
permission java.io.FilePermission "/usr/local/share/fonts/-", "read";
permission java.io.FilePermission "/usr/local/share/fonts", "read";
permission java.io.FilePermission "/usr/X11R6/lib/X11/fonts/-", "read";
permission java.io.FilePermission "/usr/X11R6/lib/X11/fonts", "read";
permission java.io.FilePermission "/System Folder/Fonts", "read";
permission java.io.FilePermission "/System/Library/Fonts", "read";
permission java.io.FilePermission "/Network/Library/Fonts", "read";
permission java.io.FilePermission "/Library/Fonts", "read";

@laurens.makel,

Thanks for providing the information about exceptions. This will help us in the future to make some overview of recommended permissions for better user experience.

@laurens.makel,

please note that the latest release of Aspose.Words for Java 24.09 has updated the bc-fips library to the latest version. As a result, aspose-words-24.9-jdk16.jar and aspose-words-24.9-jdk17.jar, as well as future releases, will work in the IBM environment. Therefore, we are discontinuing aspose-words-XX.X-jdk17ibm.jar.