Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发送出现 NoClassDefFoundError: javax.activation.DataHandler #6

Open
oy-paddy opened this issue Oct 27, 2017 · 5 comments
Open

发送出现 NoClassDefFoundError: javax.activation.DataHandler #6

oy-paddy opened this issue Oct 27, 2017 · 5 comments

Comments

@oy-paddy
Copy link

oy-paddy commented Oct 27, 2017

你好,根据你的栗子,我调用send函数后,会报错 java.lang.NoClassDefFoundError: javax.activation.DataHandler ,发送也失败。
据说要导入以下三个jia包。但是导入进去还是失败。。。

compile files('activation.jar')
compile files('mail.jar')
compile files('additionnal.jar')

我的代码如下:

package com.ouyang.sendmail;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import javax.mail.MessagingException;

import io.github.biezhi.ome.OhMyEmail;

import static io.github.biezhi.ome.OhMyEmail.SMTP_QQ;

public class MainActivity extends Activity {
    private TextView tv_send;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        OhMyEmail.config(SMTP_QQ(true), "[email protected]", "sijkpqodxyslca17");
        tv_send = (TextView) findViewById(R.id.tv_send);
        tv_send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


                try {
                    OhMyEmail.subject("这是一封测试TEXT邮件")
                        .from("王爵的QQ邮箱")
                        .to("[email protected]")
                        .text("信件内容")
                        .send();
                    Toast.makeText(MainActivity.this,"发送成功~~~",Toast.LENGTH_SHORT).show();

                } catch (MessagingException e) {
                    Toast.makeText(MainActivity.this,"发送失败哦",Toast.LENGTH_SHORT).show();

                    e.printStackTrace();
                }


            }
        });
    }
}
@chenshun00
Copy link

chenshun00 commented Oct 30, 2017

@oy-paddy 我测试是可以使用,先确认是不是开启了POP3/SMTP服务。如果没有开启,会抛异常,提示503

 OhMyEmail.config(OhMyEmail.SMTP_QQ(true), "[email protected]", "你的授权码");
        OhMyEmail.subject("这是一封测试TEXT邮件")
                .from("chenshun00的qq邮箱")
                .to("[email protected]")
                .text("信件内容")
                .send();

@oy-paddy
Copy link
Author

oy-paddy commented Oct 30, 2017

@chenshun00 服务我确认已经开启了,授权码我也填写正确了。
我调用 send 函数后,会报如下异常:

java.lang.NoClassDefFoundError: javax.activation.DataHandler

是不是还需要其他jar包支持呢?

@andylizi
Copy link
Contributor

andylizi commented Oct 30, 2017

看起来这不是这个库所专有的问题,毕竟这个库只是把 javamail api 简单的包装了一下而已。既然这个问题不限于此项目,建议 Google 一下,能得到更多通用的解决方案,解决问题的几率比在这里要大得多。

@chenshun00
Copy link

chenshun00 commented Oct 30, 2017

@oy-paddyjava.lang.NoClassDefFoundError: javax.activation.DataHandler in android 大致看了一下,这个应该可以帮助到你. ② java.lang.NoClassDefFoundError: javax.activation.DataHandler

@hellokaton hellokaton changed the title 无法发送 发送出现 NoClassDefFoundError: javax.activation.DataHandler Dec 23, 2017
@HeWanli
Copy link

HeWanli commented Apr 24, 2019

您好,发送大文件附件的时候,报错:io.github.biezhi.ome.SendMailException: com.sun.mail.smtp.SMTPSendFailedException: 451 Error: queue file write error

at io.github.biezhi.ome.OhMyEmail.send(OhMyEmail.java:308)
at io.github.biezhi.ome.OhMyEmailTest.testSendAttach(OhMyEmailTest.java:66)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

Caused by: com.sun.mail.smtp.SMTPSendFailedException: 451 Error: queue file write error

at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2358)
at com.sun.mail.smtp.SMTPTransport.finishData(SMTPTransport.java:2110)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1316)
at javax.mail.Transport.send0(Transport.java:255)
at javax.mail.Transport.send(Transport.java:124)
at io.github.biezhi.ome.OhMyEmail.send(OhMyEmail.java:306)
... 25 more

请问有解决方法吗? 我的文件80到90M左右的MP4文件。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants