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

My problem occurs with several emails but there doesn’t seem to be a problem with the email.

I’m batch exporting hundreds to thousands of messages. I can’t reproduce the exception
if I run an export with just the message that causes the problem during batch processing.

I’m seeing sporadic exceptions like this:

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

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

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

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

at com.aspose.email.hK$o.a(Unknown Source)

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

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

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

at com.aspose.email.MapiMessage.d(Unknown Source)

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

at com.aspose.email.MapiMessage.fromMailMessage(Unknown Source)

at com.aspose.email.MapiMessage.fromMailMessage(Unknown Source)


I'm using linux. My jar is aspose-email-3.6.0.0-jdk16.jar.

java version "1.7.0_17"

Java(TM) SE Runtime Environment (build 1.7.0_17-b02)

Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)

Do you have suggestions on possible workarounds?

Hi Howard,


Thanks for writing to Aspose.Email support team.

Your issue is analyzed here but could not be reproduced as more information is required in this regard. In your post you mentioned that you are exporting data i.e. bunch of EMLs to MapiMessages. Could you please elaborate if these EMLs are on disc, some server or other source? Similarly are these exported Mapi messages being stored in PST or disc only? For further investigation we also need the source EMLs which are being exported along with the sample application used for this conversion.

Moreover it is observed that you are using Aspose.Email for Java 3.6.0. Could you please test the scenario with the latest release Aspose.Email for Java 3.7.1 and provide your feedback?

The EMLs are stored on disk. The batch process is trying to export 10K EMLs but stops after 1.3K because too many exceptions are being thrown.


The method to process the EMLs looks like the following:

private PersonalStorage personalStorage;

private File tmpFile = null;

public void init() throws IOException {

tmpFile = File.createTempFile("pst-", "");

tmpFile.deleteOnExit();

personalStorage = PersonalStorage.create(tmpFile.getCanonicalPath(), FileFormatVersion.Unicode);

personalStorage.getRootFolder().addSubFolder("Downloaded");

}

public void addMessage(InputStream emlMessageInputStream, String externalBcc) throws IOException {

MailMessage mailMessage = MailMessage.load(emlMessageInputStream, MessageFormat.getEml());

if (StringUtils.isNotEmpty(externalBcc)) {

mailMessage.setBcc(MailAddressCollection.toMailAddressCollection(externalBcc));

}

if (mailMessage.getSender() == null && mailMessage.getFrom() != null) {

// Outlook likes having the "Sender" header present, even if "From" is there

mailMessage.setSender(mailMessage.getFrom());

}

MapiMessage mapiMessage = MapiMessage.fromMailMessage(mailMessage, OutlookMessageFormat.Unicode);

personalStorage.getRootFolder().getSubFolder("Downloaded").addMessage(mapiMessage);

if (logger.isTraceEnabled()) {

logger.trace("added message to pst download");

}

}

Hi Howard,


Thank you for providing the sample code you are trying at your end, which is almost the same as I have tried at my end to investigate this issue. However, I would further request you to make available the source EML files to us as sometimes it happens that the issue exists with user’s files only and doesn’t arise with pool of data available at our end. This will help us investigate the issue with your sample data and assist you further at our earliest. In the meanwhile, I have managed a pool of messages at my end and will investigate the issue with these for any possible reproduction at my end.

After the upgrade to the latest jar, the problem no longer occurs.