Runtime Error: Rejecting re-init on previously-failed class java.lang.Class<javax.activation.DataHandler>

I am using Android Studio and Java. I am trying to add an email service to send files from my project. The email service needs two jar files javax.mail and javax.activity which I added to a Libs folder for the app. I can see both jar files in the dependencies for the app. I tried to make sure I have the most update date jar. It seems like I have not added the jar files correctly or have some conflict even with another library. I get the error message below when I call the class:

08-01 16:41:20.637    1404-1404/com.microchip.mldpterminal2 I/art﹕ Rejecting re-init on previously-failed class java.lang.Class  javax.activation.DataHandler>

08-01 16:41:20.637    1404-1404/com.microchip.mldpterminal2 I/art﹕ Rejecting re-init on previously-failed class java.lang.Class javax.activation.DataHandler>

1404-1404/com.microchip.mldpterminal2 D/AndroidRuntime﹕ Shutting down VM
08-01 16:41:20.638    1404-1404/com.microchip.mldpterminal2 E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.microchip.mldpterminal2, PID: 1404
    java.lang.IllegalStateException: Could not execute method of the activity
            at android.view.View$1.onClick(View.java:4007)
            at android.view.View.performClick(View.java:4756)
            at android.view.View$PerformClick.run(View.java:19749)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at android.view.View$1.onClick(View.java:4002)
            at android.view.View.performClick(View.java:4756)
            at android.view.View$PerformClick.run(View.java:19749)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.NoClassDefFoundError: javax.activation.DataHandler
            at javax.mail.internet.MimeBodyPart.setContent(MimeBodyPart.java:717)
            at javax.mail.internet.MimeBodyPart.setText(MimeBodyPart.java:1170)
            at javax.mail.internet.MimeBodyPart.setText(MimeBodyPart.java:757)
            at javax.mail.internet.MimeBodyPart.setText(MimeBodyPart.java:741)
            at com.taavtech.scale_rev_0.emailHandler.emailhandler(emailHandler.java:67)
            at com.taavtech.scale_rev_0.DeviceControlActivity.WriteToFile(DeviceControlActivity.java:690)
            at com.taavtech.scale_rev_0.DeviceControlActivity.emailDatabuttonOnClick(DeviceControlActivity.java:630)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at android.view.View$1.onClick(View.java:4002)
            at android.view.View.performClick(View.java:4756)
            at android.view.View$PerformClick.run(View.java:19749)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

The code for the email handler was taken from a website and is listed below:

import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.activation.FileDataSource;
import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

public class emailHandler {
// File Name SendFileEmail.java

// public class SendFileEmail
    public static void emailhandler()
    {

        // Recipient's email ID needs to be mentioned.
        String to = "[email protected]";

        // Sender's email ID needs to be mentioned
        String from = "[email protected]";

        // Assuming you are sending email from localhost
        String host = "localhost";

        // Get system properties
        Properties properties = System.getProperties();

        // Setup mail server
        properties.setProperty("mail.smtp.host", host);

        // Get the default Session object.
        Session session = Session.getDefaultInstance(properties);

        try{
            // Create a default MimeMessage object.
            MimeMessage message = new MimeMessage(session);

            // Set From: header field of the header.
            message.setFrom(new InternetAddress(from));

            // Set To: header field of the header.
            message.addRecipient(Message.RecipientType.TO,
                    new InternetAddress(to));

            // Set Subject: header field
            message.setSubject("This is the Subject Line!");

            // Create the message part
            BodyPart messageBodyPart = new MimeBodyPart();

            // Fill the message
            messageBodyPart.setText("This is message body");

            // Create a multipar message
            Multipart multipart = new MimeMultipart();

            // Set text message part
            multipart.addBodyPart(messageBodyPart);

            // Part two is attachment
            messageBodyPart = new MimeBodyPart();
            String filename = "file.txt";
            DataSource source = new FileDataSource(filename);
            messageBodyPart.setDataHandler(new DataHandler(source));
            messageBodyPart.setFileName(filename);
            multipart.addBodyPart(messageBodyPart);

            // Send the complete message parts
            message.setContent(multipart );

            // Send message
            Transport.send(message);
            System.out.println("Sent message successfully....");
        }catch (MessagingException mex) {
            mex.printStackTrace();
        }
    }
}

I am stuck for the moment, and would greatly appreciate your help understanding how to fix the error.


Download runtime.error.rejecting.re.init.on.previously.failed.class.java.lang.classjavax.activation.datahandler.zip
Direct Link


Download


Download runtime.error.rejecting.re.init.on.previously.failed.class.java.lang.classjavax.activation.datahandler.zip
Mediafire


Download


Download runtime.error.rejecting.re.init.on.previously.failed.class.java.lang.classjavax.activation.datahandler.zip
Droplr


Download


Download runtime.error.rejecting.re.init.on.previously.failed.class.java.lang.classjavax.activation.datahandler.zip
Hugefiles


Download


Download runtime.error.rejecting.re.init.on.previously.failed.class.java.lang.classjavax.activation.datahandler.zip
Uptobox


Download

Both comments and pings are currently closed.

Comments are closed.