Free Support Forum - aspose.com

Aspose.Email compatability in with JDK12

Hi team,
I have using Aspose.email 19.5 for Java, i am using Exchange web services. It thows and exception :
Exception in thread "pool-1-thread-1" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

at com.aspose.email.EWSClient.getEWSClient(SourceFile:301)

at com.aspose.email.EWSClient.getEWSClient(SourceFile:280)

at com.aspose.email.EWSClient.getEWSClient(SourceFile:126)

at MainFrame.getEWSClient(MainFrame.java:1212)

at MainFrame$17$2.run(MainFrame.java:1000)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)

at java.base/java.lang.Thread.run(Thread.java:835)

Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException

at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)

at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)

at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)

… 8 more

I have run my project in jdk 8 , it’s working there but when i switch jdk version 8 to 12, it’s not working

@pradeepnegi,

I have observed your requirements related to Java 12 compatibility with Aspose.Email for Java. Can you please share the source code used on your end so that I may log investigation ticket on our end.

This is the code i am using.

import java.io.File;
import java.io.IOException;

import com.aspose.email.EWSClient;
import com.aspose.email.ExchangeFolderInfo;
import com.aspose.email.ExchangeFolderInfoCollection;
import com.aspose.email.ExchangeFolderType;
import com.aspose.email.ExchangeMessageInfo;
import com.aspose.email.ExchangeMessageInfoCollection;
import com.aspose.email.IEWSClient;
import com.aspose.email.MailMessage;

public class Demo {

static class D{
	static void listAllFolders() {
		
		String String="abc";
		fun(String);
		try
		{
			String rootfolder="Root";
			IEWSClient client = EWSClient.getEWSClient("https://outlook.office365.com/ews/exchange.asmx", 
					"", "","");
			String rootUri = client.getMailboxInfo().getRootUri();
			client.setTimeout(Integer.MAX_VALUE);
			System.out.println("Downloading all messages from Inbox....");

			// List all the folders from Exchange server
			ExchangeFolderInfoCollection folderInfoCollection = client.listSubFolders(rootUri);
			int size=folderInfoCollection.size();

			for (int i=0;i<size;i++) 
			{
				ExchangeFolderInfo folderInfo=folderInfoCollection.get_Item(i);
				// Call the recursive method to read messages and get sub-folders
				//System.out.println(folderInfo.getDisplayName());
				listSubFolders(client, folderInfo,rootfolder);
			}

			System.out.println("All messages downloaded.");
		}
		catch (Exception ex) {
			System.out.println(ex.getMessage());
		}
		
		System.out.println(ExchangeFolderType.Undefined);
		System.out.println(ExchangeFolderType.Note);
		System.out.println(ExchangeFolderType.RSSFeeds);
		System.out.println(ExchangeFolderType.Appointment);
		System.out.println(ExchangeFolderType.Contact);
		System.out.println(ExchangeFolderType.QuickContacts);
		System.out.println(ExchangeFolderType.ImContactsList);
		System.out.println(ExchangeFolderType.DocumentLibraries);
		System.out.println(ExchangeFolderType.Journal);
		System.out.println(ExchangeFolderType.StickyNote);
		System.out.println(ExchangeFolderType.Task);
		System.out.println(ExchangeFolderType.Imap);
		System.out.println(ExchangeFolderType.Unknown);
		
		System.out.println(new File("C:\\Users\\DELL\\Desktop\\abc\\a").mkdirs());
	}
	
	private static void fun(String String) {
		// TODO Auto-generated method stub
		
	}
}


private final static void listSubFolders(IEWSClient client, ExchangeFolderInfo folderInfo,String rootFolder) {
	try
	{
		// Create the folder in disk (same name as on IMAP server)
		String path=rootFolder+"\\"+folderInfo.getDisplayName();
		System.out.println(path);
		// If this folder has sub-folders, call this method recursively to get messages
		ExchangeFolderInfoCollection folderInfoCollection = client.listSubFolders(folderInfo.getUri());
		
		ExchangeMessageInfoCollection msgInfoColl = client.listMessages(folderInfo.getUri());
		int msgsize=msgInfoColl.size();
		System.out.println(msgsize);
		
		for(int i=0;i<msgsize;i++)
		{
			ExchangeMessageInfo exmsg=msgInfoColl.get_Item(i);
			
			MailMessage msg=client.fetchMessage(exmsg.getUniqueUri());
			System.out.println(msg.getSubject());
			System.out.println(msg.getFrom());
			System.out.println("----------------------------------");
		}
		
		int size=folderInfoCollection.size();
		
		if(size>0)
		{
			//System.out.println("sub folders-");
			for (int i=0;i<size;i++)
			{
				ExchangeFolderInfo subfolderInfo=folderInfoCollection.get_Item(i);
				listSubFolders(client,subfolderInfo,path);
			}
		}
	}
	catch (Exception ex) 
	{
		System.out.println(ex.getMessage());
	}
}

public static void main(String[] args) throws IOException {
	Demo dm=new Demo();
	Demo.D.listAllFolders();
}

}

@pradeepnegi,

I have observed the issue shared and an issue with ID EMAILJAVA-34560 has been created as investigation to further investigate compatibility of Aspose.Email with Java 12. We will share good news with you as soon as support will be available in API.

Hi Team,

I am new here and i just want to know Aspose.Email compatibility in with JDK8 (Java)
if its compatibility with JDK8 then please share me maven dependency and java source code.

Thanks In Advance !!
Pankaj

@pankajastegic,
Welcome to our community! Thank you for your query. I will continue to reply to you in the next topic.