java.lang.ExceptionInInitializerError after update to Aspose Words 21.6

Trying to update Aspose Words from Version 21.4 to 21.6 (same problem with 21.5). Running into the following exception. To isolate the issue I created a simple OSGi bundle (see manifest below). The Problem does not happen if only the Jar is used instead of the OSGi dependency.

	org.osgi.framework.BundleException: Ausnahme in aspose.word.osgi.test.Activator.start() von Bundle aspose.word.osgi.test.
	at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:835)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:763)
	at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1012)
	at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:366)
	at org.eclipse.osgi.container.Module.doStart(Module.java:605)
	at org.eclipse.osgi.container.Module.start(Module.java:468)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1845)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1838)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1743)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1665)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)
Caused by: java.lang.ExceptionInInitializerError
	at com.aspose.words.zzXjl.zzWXs(Unknown Source)
	at com.aspose.words.zzXjl.zzXHL(Unknown Source)
	at com.aspose.words.zzWh8.zzpw(Unknown Source)
	at com.aspose.words.Document.zzYl6(Unknown Source)
	at com.aspose.words.Document.zzWXs(Unknown Source)
	at com.aspose.words.Document.zzWWx(Unknown Source)
	at com.aspose.words.Document.<init>(Unknown Source)
	at com.aspose.words.Document.<init>(Unknown Source)
	at aspose.word.osgi.test.Activator.start(Activator.java:38)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:814)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:806)
	... 14 more
Caused by: java.lang.IllegalStateException: Invalid license signature. Please make sure the license file was not modified.
	at com.aspose.words.zzWS3.<init>(Unknown Source)
	at com.aspose.words.zzWS3.<clinit>(Unknown Source)
	... 27 more
Root exception:
java.lang.ExceptionInInitializerError
	at com.aspose.words.zzXjl.zzWXs(Unknown Source)
	at com.aspose.words.zzXjl.zzXHL(Unknown Source)
	at com.aspose.words.zzWh8.zzpw(Unknown Source)
	at com.aspose.words.Document.zzYl6(Unknown Source)
	at com.aspose.words.Document.zzWXs(Unknown Source)
	at com.aspose.words.Document.zzWWx(Unknown Source)
	at com.aspose.words.Document.<init>(Unknown Source)
	at com.aspose.words.Document.<init>(Unknown Source)
	at aspose.word.osgi.test.Activator.start(Activator.java:38)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:814)
	at org.eclipse.osgi.internal.framework.BundleContextImpl$2.run(BundleContextImpl.java:1)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:806)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:763)
	at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:1012)
	at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:366)
	at org.eclipse.osgi.container.Module.doStart(Module.java:605)
	at org.eclipse.osgi.container.Module.start(Module.java:468)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel$2.run(ModuleContainer.java:1845)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor$1$1.execute(EquinoxContainerAdaptor.java:136)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1838)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1781)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1743)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1665)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:234)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:345)
Caused by: java.lang.IllegalStateException: Invalid license signature. Please make sure the license file was not modified.
	at com.aspose.words.zzWS3.<init>(Unknown Source)
	at com.aspose.words.zzWS3.<clinit>(Unknown Source)
	... 27 more

MANIFEST.MF

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test
Bundle-SymbolicName: aspose.word.osgi.test;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: aspose.word.osgi.test
Bundle-RequiredExecutionEnvironment: JavaSE-15
Import-Package: com.aspose.words;version="21.6.0",
 org.osgi.framework
Bundle-Activator: aspose.word.osgi.test.Activator
Require-Bundle: com.aspose.words;bundle-version="21.6.0"
Bundle-ActivationPolicy: lazy

Activator.java

package aspose.word.osgi.test;

import java.net.URL;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

import com.aspose.words.Document;

public class Activator implements BundleActivator {

	@Override
	public void start(BundleContext bundleContext) throws Exception {
		// load the license
		URL licenseUrl = bundleContext.getBundle().getResource("resource/license/Aspose.Total.Java.lic"); //$NON-NLS-1$
		if (licenseUrl == null) {
			throw new Exception("license resource not found"); //$NON-NLS-1$
		}

		try {
			com.aspose.words.License wordsLicense = new com.aspose.words.License();
			wordsLicense.setLicense(licenseUrl.openStream());
		} catch (Exception e) {
			throw new Exception("failed to activate license for Aspose Words", e); //$NON-NLS-1$
		}

		try {
			Document doc = new Document();
			doc.save("d:/temp/result.docx");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void stop(BundleContext bundleContext) throws Exception {

	}
}

A post was split to a new topic: java.lang.ExceptionInInitializerError is thrown after update to Aspose Words 21.6

@phe

We have tested the scenario using Java 8 and have not faced the shared issue.

Aspose.Words for Java throws exception while creating document with Java 7. We logged this issue as WORDSJAVA-2604 in our issue tracking system. We apologize for your inconvenience.

Could you please share the Java version that you are using? We will investigate the issue and provide you more information on it.

I encounter this issue with Java 16.0.1.

@phe

Please upgrade to the latest version of Aspose.Words for Java 21.6 and let us know if you face the same issue. Please also share the Java version that you are using.

As stated in the title and description this happens with aspose words 21.6 and also 21.
5.

@tahir.manzoor

We encountered this problem using Java 11 and Words 21.6 (version JDK17, not JDK16 Only).

I would like to draw your attention to the exception stack trace shared by @phe, which is the same as ours. In addition to the exception that says there was a problem creating the Document instance (Caused by: java.lang.ExceptionInInitializerError), there is another important one that can be crucial, and that is an exception that is generated because the Words API does not recognize the license (Caused by: java.lang.IllegalStateException: Invalid license signature. Please make sure the license file was not modified.), and the license is certainly valid.

Nenad

A post was split to a new topic: WORDSNET-22294

@phe

We are investigating this issue and will get back to you soon.

@phe

We have logged this problem in our issue tracking system as WORDSJAVA-2607. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

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

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