java.lang.NoClassDefFoundError: Could not initialize class com.aspose.email.bq

Hello,


we use Aspose Mail for Java with a latest version 2.3.0 to convert EML to PDF.

The Aspose is running as a web application in this environment:

- Windows Server 2008 R2 Enterprise (64 bit)

- Sun/Oracle JDK 1.6.0_37 (64 bit)

- Tomcat 6.0.29


By execution of this code:

readerInputStream = ... (Input Stream from the attached EML file)

com.aspose.email.MailMessage message = com.aspose.email.MailMessage.load(readerInputStream,
MessageFormat.getEml());

...

Aspose throws the error:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.aspose.email.bq

at com.aspose.email.aD.a(Unknown Source)

at com.aspose.email.aD.a(Unknown Source)

at com.aspose.email.gn.c(Unknown Source)

at com.aspose.email.gn.a(Unknown Source)

at com.aspose.email.gn.b(Unknown Source)

at com.aspose.email.MailMessage.a(Unknown Source)

at com.aspose.email.MailMessage.load(Unknown Source)


What is interesting, that the same code runs on Linux (Ubuntu) and OS X.

So it seems to be related to the Windows Server 2008 R2 Enterprise (64 bit) server environment.

Thanks in advance fro your help!

Best regards

Vitali






Hi Vitali,


We are afraid for the inconvenience you are facing.

Can you please tell us if this issue happens with this specific EML file only? Are you able to process other EML files in the same Windows Server 2008 environment? I would request you to please provide us your sample web app if possible so as we can test it at our end and analyze if we get the same error. We will try to assist you further on this as soon as possible.

Hello Kashif,


because of License reasons, it’s difficult to attach you the whole web-app, but here is the source code:

import com.aspose.email.MailMessage;

import com.aspose.email.MailMessageSaveType;

import com.aspose.email.MessageFormat;

import com.aspose.words.Document;

import com.aspose.words.SaveFormat;

MailMessage message = MailMessage.load(“test.eml”,

MessageFormat.getEml());

System.out.println(“Saving message in MHTML format…”);

File file = File.createTempFile(String.valueOf(new Date().getTime()),

".mhtml");

// Save the message in MHTML format

message.save(file.getAbsolutePath(), MailMessageSaveType

.getMHtmlFromat());


In the bold marked text, is the code, which doesn’t work on Windows Serverv 2008 R2. Would it help for your investigations?


Best regards

Vitali



Hi Vitali,


Thanks for providing the supporting code.

I would request you to please spare us a little time so that we can investigate this issue at our end. We will be back to you on this once and share our findings as soon as possible. Your patience in this regard is highly appreciated.

Hi Vitali,

Thank you for being patient.

I tried to reproduce this issue at my end, but I am afraid to share with you that I couldn't get success in this. I used the same configurations as you mentioned and the code executed without any error. I have attached a screenshot of the email contents that the code has retrieved and printed to the output for your reference. Can you please check if you can execute other EML files successfully in the same environment? Please let us know your feedback then.

Hello Kashif,


thanks for testing this. I wrote a small java program to test this behavior and here my results:

In this environment:
Windows Server 2008 R2 Enterprise (64 bit), Sun/Oracle JDK 1.6.0_37 (64 bit), Tomcat 6.0.29

Using code I’ve attached, Aspose throws the error below. On other systems, such as: Linux, Mac, Windows with Java 7, everything works fine.

Can you please set up the same environment I’ve described and run my code with it (see AsposeMailToPDFTransformer.java.zip)?

To run this program you need to create:
a. A file with Aspose mail license: ./license/Aspose.Email.Java.lic
b. Any EML to test: in ./test/test.eml

ERROR STACK TRACE:

Exception in thread "main" java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa

der.java:56)

Caused by: java.lang.ExceptionInInitializerError

at com.aspose.email.aD.a(Unknown Source)

at com.aspose.email.aD.a(Unknown Source)

at com.aspose.email.gm.c(Unknown Source)

at com.aspose.email.gm.a(Unknown Source)

at com.aspose.email.gm.a(Unknown Source)

at com.aspose.email.gm.b(Unknown Source)

at com.aspose.email.MailMessage.a(Unknown Source)

at com.aspose.email.MailMessage.load(Unknown Source)

at AsposeMailToPDFTransformer.main(AsposeMailToPDFTransformer.java:28)

... 5 more

Caused by: java.lang.NullPointerException

at com.aspose.email.private.d.b.d(Unknown Source)

at com.aspose.email.bq.a(Unknown Source)

at com.aspose.email.bq.(Unknown Source)

... 14 more


Best regards
Vitali

Hello again,


we’ve found a root case of this issue.

Aspose seems to not work with Sun/Oracle JDK 1.6.0_37 (64 bit).

Updating to the JDK 7 solved this issue.

Unfortunately we can’t us this solution for production installation, because Software where we integrate Aspose official doesn’t support Java 7.

Is it possible to fix this problem for Sun/Oracle JDK 1.6.0_37 (64 bit)? Particularly we use aspose-email-2.3.0.0-jdk16.jar, which is supposed to run with Java 6.

Or if you can tell me which JDK 6 version update (see here Java Archive Downloads - Java SE 6) is officially supported by Aspose Mail, it would also be fine, cause we simply need a Java 6 version which works with Aspose on Windows Server 2008 R2 64 bit.

Best regards
Vitali

Hello Vitali,


Thank you for the feedback.

I was unable to to browse the Java 6 versions link that you have mentioned in your last post.

My Setup:

I tested this issue by downloading JDK 1.6.0_37-x64 from this LINK. The Windows Server 2008 R2 at my end has Tomcat 7.0.30 installed on it. I retrieved the information from your test EML file by simply loading it using MailMessage.Load method. I have searched through Aspose.Email documentation as well and couldn’t find any such information about Aspose.Email not working with JDK 1.6.0_37. Please spare us some time so that I can further investigate this issue and also sought help from development team in this regard.

Hi Kashif,


I’m not sure about Tomcat 7, our application is running with Tomcat 6.

Can you please run the code I’ve attached without Tomcat? Simple using the command line:
java AsposeMailToPDFTransformer?

(Before running this code, see steps I’ve described in my previous post regarding license and test.eml)

Important that JDK 1.6.0_37-x64 is installed and code is running on Windows Server 2008 R2 64bit.

We can reproduce this anytime.

Best regards
Vitali

Hi Vitali,


Sorry for a delayed response.

I have tested this scenario as per the steps you have mentioned. Please have a look at the attached screenshot for your reference. I have compiled and run the code from command line as per your requirements. The underlying environment is Windows Server 2008 R2 64 bit with JDK 1.6.0_37-x64 (from the download link that I mentioned in my early post). Can you please tell us if this happens with any other EML file as well on the same environment as you mentioned) or not? Please make sure that the classpath is set properly in the execution command as you can see in the reference screenshot attached.

Hi Kashif,


>> Can you please tell us if this happens with any other EML file as well on the same environment as you >> mentioned) or not?
it happens with any EML we have.
I have no idea, why it works by you.

I’ll investigate it further and send you details about results.

Thanks for your help.

Best regards
Vitali

Hi Vitali,


At my end, it is working for all type of files and I was unable to reproduce this issue with the same environment as you mentioned. Please let me know if I can be of any additional help to you. It will be pleasure assisting you further.