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

Free Support Forum - aspose.com

UnsupportedClassVersionError paid version

Hi I am using a paid version of Aspose Total for Java and trying to convert word documents to pdf and I am running into UnsupportedClassVersionError during the convertion.

public static byte[] WordToPdf (byte[] WordData,String extension) throws Exception{
com.aspose.words.License lic = new com.aspose.words.License();
ByteArrayInputStream inStream = new ByteArrayInputStream(WordData);
Document doc = new Document(inStream);
ByteArrayOutputStream outputstream = new ByteArrayOutputStream();
doc.save(outputstream, SaveFormat.PDF);
return outputstream.toByteArray();
Error message:
08/01/19 17:52:54:920 CET] 000003cc RemoteExcepti E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method “doAjaxCall” on bean “BeanId(scl_case#SonoraBeans.jar#com.eistream.sonora.system.SystemSessionEJBHome, null)”. Exception data: java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=com/aspose/pdf/Document, offset=6
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:331)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:155)
at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:857)
at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:765)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:606)
at java.lang.ClassLoader.loadClass(ClassLoader.java:741)
at nl.aegon.case360.filestore.PdfUtil.WordToPdf(PdfUtil.java:198)

Environment details : we are running on WAS 8.5 on a linux environment with JDK 1.7
Jars used : aspose-words-18.9-jdk16.jar,aspose-pdf-18.12-jdk17.jar


Thanks for your inquiry. In your code, you are converting document to PDF using Aspose.Words. However, the stack trace shows that this issue is related to Aspose.PDF. Could you please share following detail for investigation?

  1. Please share if you are facing this issue using Aspose.PDF. Please share the code example of Aspose.PDF that throws this exception.
  2. Are you facing this issue with all documents or with specific document?

@tahir.manzoor As you mentioned for converting word if I use Aspose.words it works fine. I tried to use Aspose.Pdf to convert image file to PDF I get the same UnsupportedClassVersionError. Please find the below code sample.

public static byte[] ImageToPdf(byte[] imageData, String extension) throws Exception
com.aspose.pdf.License license = new com.aspose.pdf.License();
ByteArrayInputStream inStream = new ByteArrayInputStream(imageData);
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
Page page = doc.getPages().add();
// Set margins so image will fit, etc.
page.setCropBox(new Rectangle(0, 0, 400, 400));
// Create an image object
Image image1 = new Image();
// Add the image into paragraphs collection of the section
// Set the image file stream
// Save resultant PDF file
ByteArrayOutputStream outputstream = new ByteArrayOutputStream();
return outputstream.toByteArray(); 


aspose-pdf-18.12.jar is compiled with java version 1.8 but we still use 1.7 compiler. I also saw some warnings for bad major version during the build.

For example:
[javac] warning: C:\Workspaces\Case4Life_Git\case4life\Common\lib\aspose-pdf-18.12.jar(com/aspose/pdf/License.class): major version 52 is newer than 51, the highest major version supported by this compiler.
[javac] It is recommended that the compiler be upgraded.

Can you please suggest which version of Aspose.pdf I should be using for java 1.7 compiler. Or is there any way to use the latest Aspose.pdf with Java 1.7 compiler


Thank you for elaborating it further.

Would you please ensure using aspose-pdf-18.12-jdk17.jar with JDK 1.7 in your environment and then share your kind feedback with us.

In case the issue persists then please share complete JDK version and name of JAR file being used, along with a sample application reproducing this issue so that we may try to reproduce and investigate it further.