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

Free Support Forum - aspose.com

Strange exception in multi-threaded environment

When I’m trying to add eml to PST on Linux in multi-threaded flow I get this exception, it’s not happening all the time, so I can’t provide you a sample data to reproduce :
07:48:39 java.lang.ExceptionInInitializerError
Nov 6 07:48:39 at com.aspose.email.fj.(SourceFile:18)
Nov 6 07:48:39 at com.aspose.email.ew.(SourceFile:167)
Nov 6 07:48:39 at com.aspose.email.bas.(SourceFile:29)
Nov 6 07:48:39 at com.aspose.email.kd.(SourceFile:41)
Nov 6 07:48:39 at com.aspose.email.aow$o.a(SourceFile:371)
Nov 6 07:48:39 at com.aspose.email.aow.a(SourceFile:1963)
Nov 6 07:48:39 at com.aspose.email.fh.a(SourceFile:208)
Nov 6 07:48:39 at com.aspose.email.fb.b(SourceFile:326)
Nov 6 07:48:39 at com.aspose.email.fb.a(SourceFile:250)
Nov 6 07:48:39 at com.aspose.email.fb.a(SourceFile:235)
Nov 6 07:48:39 at com.aspose.email.MailMessage.t(SourceFile:3810)
Nov 6 07:48:39 at com.aspose.email.MailMessage.a(SourceFile:3799)
Nov 6 07:48:39 at com.aspose.email.MailMessage.a(SourceFile:3441)
Nov 6 07:48:39 at com.aspose.email.MailMessage.a(SourceFile:229)
Nov 6 07:48:39 at com.aspose.email.MailMessage.(SourceFile:223)
Nov 6 07:48:39 at com.aspose.email.MailMessage.a(SourceFile:1413)
Nov 6 07:48:39 at com.aspose.email.MailMessage.b(SourceFile:1343)
Nov 6 07:48:39 at com.aspose.email.MailMessage.load(SourceFile:1296)

Nov 6 07:48:39 Caused by: class com.aspose.email.system.exceptions.ArgumentException: element already exists
Nov 6 07:48:39 com.aspose.email.system.collections.generic.SortedList.a(Unknown Source)
Nov 6 07:48:39 com.aspose.email.system.collections.generic.SortedList.addItem(Unknown Source)
Nov 6 07:48:39 com.aspose.email.ayl.d(SourceFile: 335)
Nov 6 07:48:39 com.aspose.email.ayl.c(SourceFile: 127)
Nov 6 07:48:39 com.aspose.email.ayl.(SourceFile: 599)
Nov 6 07:48:39 com.aspose.email.fj.(SourceFile: 18)
Nov 6 07:48:39 com.aspose.email.ew.(SourceFile: 167)
Nov 6 07:48:39 com.aspose.email.bas.(SourceFile: 29)
Nov 6 07:48:39 com.aspose.email.kd.(SourceFile: 41)
Nov 6 07:48:39 com.aspose.email.aow$o.a(SourceFile: 371)
Nov 6 07:48:39 com.aspose.email.aow.a(SourceFile: 1963)
Nov 6 07:48:39 com.aspose.email.fh.a(SourceFile: 208)
Nov 6 07:48:39 com.aspose.email.fb.b(SourceFile: 326)
Nov 6 07:48:39 com.aspose.email.fb.a(SourceFile: 250)
Nov 6 07:48:39 com.aspose.email.fb.a(SourceFile: 235)
Nov 6 07:48:39 com.aspose.email.MailMessage.t(SourceFile: 3810)
Nov 6 07:48:39 com.aspose.email.MailMessage.a(SourceFile: 3799)
Nov 6 07:48:39 com.aspose.email.MailMessage.a(SourceFile: 3441)
Nov 6 07:48:39 com.aspose.email.MailMessage.a(SourceFile: 229)
Nov 6 07:48:39 com.aspose.email.MailMessage.(SourceFile: 223)
Nov 6 07:48:39 com.aspose.email.MailMessage.a(SourceFile: 1413)
Nov 6 07:48:39 com.aspose.email.MailMessage.b(SourceFile: 1343)
Nov 6 07:48:39 com.aspose.email.MailMessage.load(SourceFile: 1296)

Please advise.


Writing to PST in multi-threaded application is not supported completely and that is why you are getting exception. We have this feature request already logged in our issue tracking system but there are no near future plans for supporting this functionality. Please let us know if we can be of any additional help to you.

It’s not that I created one PST from multiple threads, it’s each thread creates it’s own PST.


Please share your sample code and environment details with us. Ideally, this should not raise any issue as we have tested this scenario a number of times in past.

Well, the sample code in this case is our entire app and I can’t share it, but simple creation of the PST and loading EMLs to it. And this repeats in 15 threads (each thread creates it’s own PST). This runs on CentOS Linux in Java 8 Update 60.



We have tested this on windows environment and couldn’t reproduce the issue. We’ll now setup environment for testing the same on CentOS Linux that may require us a little time. We’ll soon update you here with our findings.


We couldn’t reproduce the issue at our end with specified environment. Could you please share with us how are you initializing your PST file? Please share sample code that we can use to reproduce the issue at our end.

I’m not aware about different ways to initialize the PST :
Preformatted text`PersonalStorage.create(“name”, FileFormatVersion.Unicode);

This is how we creates the PST.


As mentioned earlier, we couldn’t reproduce the issue at our end with the mentioned environment and the issue seems specific to your application. It will be of utmost help if you could create a sample application which creates pst and adds messages to these in threads, giving rise to exception and share that with us. We’ll use that in our environment for reproducing the same and assist you further.