We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Words for Java throws exception when obfuscated by proguard maven plugin

Hi there,
I’m getting the following exception when the build has proguard to offuscate the code:

java.lang.Exception: java.lang.NoClassDefFoundError: com/sun/imageio/plugins/gif/GIFImageMetadata
at com.aspose.words.internal.zzND.zzZ(Unknown Source)
at com.aspose.words.internal.zzND.zzY(Unknown Source)
at com.aspose.words.internal.zzYH.zzZ(Unknown Source)
at com.aspose.words.internal.zzYH.(Unknown Source)
at com.aspose.words.internal.zzYH.(Unknown Source)
at com.aspose.words.zzZO2.zzZc(Unknown Source)
at com.aspose.words.zzZO2.zzg(Unknown Source)
at com.aspose.words.zzZO2.setImageBytes(Unknown Source)
at com.aspose.words.ImageData.setImageBytes(Unknown Source)
at com.aspose.words.DocumentBuilder.insertImage(Unknown Source)
at com.aspose.words.DocumentBuilder.insertImage(Unknown Source)
at com.aspose.words.DocumentBuilder.insertImage(Unknown Source)

Without proguard, it works fine. Is there any special config that should I add to proguard config?

Thank you.

@rmrodrigues

Could you please share the complete steps that you are following to reproduce this issue at our side? We will investigate the issue and provide you more information on it.

Hi @tahir.manzoor,
I have an application which is obfuscated by using this maven plugin:

If we run the app without obfuscation it works fine, with proguard is throws an exception when I add an GIF imaged to the document.(Word doc in this case).
It seems that with obfuscation the class com/sun/imageio/plugins/gif/GIFImageMetadata is not imported/loaded to classloarder.

java.lang.Exception: java.lang.NoClassDefFoundError: com/sun/imageio/plugins/gif/GIFImageMetadata
at com.aspose.words.internal.zzND.zzZ(Unknown Source)
at com.aspose.words.internal.zzND.zzY(Unknown Source)
at com.aspose.words.internal.zzYH.zzZ(Unknown Source)
at com.aspose.words.internal.zzYH.(Unknown Source)
at com.aspose.words.internal.zzYH.(Unknown Source)
at com.aspose.words.zzZO2.zzZc(Unknown Source)
at com.aspose.words.zzZO2.zzg(Unknown Source)
at com.aspose.words.zzZO2.setImageBytes(Unknown Source)
at com.aspose.words.ImageData.setImageBytes(Unknown Source)
at com.aspose.words.DocumentBuilder.insertImage(Unknown Source)
at com.aspose.words.DocumentBuilder.insertImage(Unknown Source)
at com.aspose.words.DocumentBuilder.insertImage(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: com/sun/imageio/plugins/gif/GIFImageMetadata
at com.aspose.words.internal.zzNJ.zzZ(Unknown Source)
… 29 more
Caused by: java.lang.ClassNotFoundException: com.sun.imageio.plugins.gif.GIFImageMetadata not found by OurApp [274]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1639)
at org.apache.felix.framework.BundleWiringImpl.access$200(BundleWiringImpl.java:80)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

@rmrodrigues

I think, you can resolve the problem with the following ProGuard configuration. Hope this helps you.

-keep class asposewobfuscated.** { ; }
-keep class com.aspose.
* { *; }
-dontnote asposewobfuscated.
-dontwarn com.aspose.

Same problem.
Could this be a classpath/classloader issue?

@rmrodrigues

Your issue is more related to ProGuard configuration setting. We suggest you please use the latest version of Aspose.Words for Java 20.7.

If you still face problem, please share the following detail here for our reference. We will then provide you more information about your query.

  • Your word document and Java application.
  • Operating system and Java version that you are using.
  • I think, you are using Aspose.Words for Java. Please confirm.
  • Please share step by step detail that help use to reproduce this issue at our end.

Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.