Bot task java.lang.ClassCastException: javax.mail.internet.MimeMultipart

Hi. I have mail reader bot task, see script bellow. Mail reader is a java app. I call java main class from script:

<?xml version="1.0" encoding="UTF-8"?>
	<config xmlns="" scriptlang="groovy">
				               import org.emailspamfilter.controller.EmailSpamController           
				               import org.emailspamfilter.textclassifier.EmailTextClassifier    
				               import org.emailspamfilter.listener.EmailListener 

It’s work fine from eclipse or studio, but when I launch business process in control tower, I see error:
java.lang.ClassCastException: javax.mail.internet.MimeMultipart cannot be cast to javax.mail.internet.MimeMultipart.

I found a problem string in code: MimeMultipart mimeMultipart = (MimeMultipart) message.getContent();

Full code part:

	   private String getTextFromMessage(Message message) throws MessagingException, Exception{
		   String result = "";		    
				if (message.isMimeType("text/plain")) {
				    result = message.getContent().toString();				    
				} else if (message.isMimeType("multipart/*")) {
					MimeMultipart mimeMultipart = (MimeMultipart) message.getContent();		
				    result = getTextFromMimeMultipart(mimeMultipart);

		    return result;

		private String getTextFromMimeMultipart(
				MimeMultipart mimeMultipart) throws MessagingException, IOException  {
		    String result = "";

		    //int count = mimeMultipart.getCount();
		   // for (int i = 0; i < count; i++) {
				for (int i = 0; i < mimeMultipart.getCount(); i++) {
				    BodyPart bodyPart = mimeMultipart.getBodyPart(i);
				    if (bodyPart.isMimeType("text/plain")) {
				        result = result + "\n" + bodyPart.getContent();
				        break; // without break same text appears twice in my tests
				    } else if (bodyPart.isMimeType("text/html")) {
				        String html = (String) bodyPart.getContent();
				        result = result + "\n" + Jsoup.parse(html).text();
				    } else if (bodyPart.getContent() instanceof MimeMultipart){
				        result = result + getTextFromMimeMultipart((MimeMultipart)bodyPart.getContent());

		    return result;