Java.lang.noclassdeffounderror:com/sun/mail/util/maillogger javax/mail/messagingexception

Source: Internet
Author: User
Tags java se

About two errors encountered while using JavaMail

1.java.lang.noclassdeffounderror:com/sun/mail/util/maillogger

2.java.lang.noclassdeffounderror:javax/mail/messagingexception


Pom.xml originally configured

<dependency>
    <groupid >javax.mail </groupid >
    <artifactid >javax.mail-api</ artifactid>
    <version >1.5.1 </version >
    <scope >test </scope >
</ Dependency>

Solution:

1.java.lang.noclassdeffounderror:com/sun/mail/util/maillogger

Maillogger--is part of the JavaMail, included in the Java EE environment, but not included in the Java SE environment, the big reason for this error is to test the sending of messages in the SE environment JAVAX.MAIL-API is only suitable for compiling, but if you really want to run the code, you must fully implement JavaMail can use <groupid>com.sun.mail</groupid><artifactid >javax.mail</artifactId>
Reference: http://stackoverflow.com/questions/16807758/ Java-lang-noclassdeffounderror-com-sun-mail-util-maillogger-for-junit-test-case
Pom.xml modified to

<span style= "White-space:pre" >	</span><dependency >
            <groupid >com.sun.mail </ GroupId >
            <artifactid >javax.mail </artifactid >
            <version >1.5.4 </version >
        </dependency >



Then a second error occurs 2.java.lang.noclassdeffounderror:javax/mail/messagingexception
is because you need to mail.jar this jar bag.
Reference: http://javahonk.com/java-lang-classnotfoundexception-javax-mail-messagingexception/
The final pom.xml revision was changed to
        <dependency >
            <groupid >javax.mail </groupid >
            <artifactid >mail </artifactid >
            <version >1.4.5 </version >
        </dependency >
        <dependency >
            <groupid > Com.sun.mail </groupid >
            <artifactid >javax.mail </artifactid >
            <version >1.5.4 </ Version >
        </dependency >




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.