class file for javax.mail.internet.MimeMessage not found
Asked Answered
T

5

21

I am getting following error while building my project.

City\controller\MyMailHelper.java:59: cannot access javax.mail.internet.MimeMessage
class file for javax.mail.internet.MimeMessage not found

In application code I am referring following imports.

import org.springframework.mail.javamail.MimeMailMessage;
import org.springframework.mail.javamail.MimeMessageHelper;

Spring dependency taken from the maven dependency tree of my project is given below . Could someone help me to identify which dependency is making this problem.

Line 27:  |  +- org.springframework:spring-jdbc:jar:3.2.1.RELEASE:compile (version managed from 3.2.1.RELEASE; scope managed from compile)
    Line 28:  |  +- org.springframework:spring-orm:jar:3.2.1.RELEASE:compile (version managed from 3.2.1.RELEASE; scope managed from compile)
    Line 29:  |  +- org.springframework:spring-jms:jar:3.2.1.RELEASE:compile (version managed from 3.2.1.RELEASE; scope managed from compile)
    Line 52:  |  +- org.springframework:spring-beans:jar:3.2.1.RELEASE:compile (version managed from 3.2.1.RELEASE; scope managed from compile
    Line 53:  |  +- org.springframework:spring-aop:jar:3.2.1.RELEASE:compile (version managed from 3.2.1.RELEASE; scope managed from compile)
    Line 64:  +- org.springframework:spring-core:jar:3.2.1.RELEASE:compile
    Line 65:  +- org.springframework:spring-context:jar:3.2.1.RELEASE:compile
    Line 66:  |  \- org.springframework:spring-expression:jar:3.2.1.RELEASE:compile
    Line 67:  +- org.springframework:spring-web:jar:3.2.1.RELEASE:compile
    Line 69:  +- org.springframework:spring-webmvc:jar:3.2.1.RELEASE:compile
    Line 74:  |  +- org.springframework.ws:spring-ws:jar:all:2.0.5.RELEASE:compile
    Line 77:  |  +- org.springframework:spring-tx:jar:3.1.3.RELEASE:compile
    Line 90:  |  +- org.springframework.ws:spring-ws-core:jar:2.1.2.RELEASE:compile (version managed from 2.1.2.RELEASE)
    Line 91:  |  |  +- org.springframework.ws:spring-xml:jar:2.1.2.RELEASE:compile
    Line 93:  |  +- org.springframework:spring-oxm:jar:3.2.1.RELEASE:compile
    Line 99:  +- org.springframework:spring-test:jar:3.2.1.RELEASE:test
Twopence answered 12/12, 2013 at 12:58 Comment(0)
S
32

It appears you are missing a dependency on javax.mail.

Try adding this to your Maven dependencies.

<dependency>
   <groupId>javax.mail</groupId>
   <artifactId>mail</artifactId>
   <version>1.4.7</version>
</dependency>
Scribe answered 12/12, 2013 at 16:23 Comment(2)
I am using org.springframework.mail.javamail. It could be an issue with multiple JARs importing the same mail package, but not sure which are those jars.Twopence
Thx bparry, you were correct. I was using that as transitive dependency in my project and for some reason that project's jar was not downloading from repo. It worked fine today.Twopence
T
4

Just remove the version from the following dependency.

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-mail</artifactId>
</dependency>
Troglodyte answered 28/11, 2023 at 5:55 Comment(0)
U
2

bparry's answer still hold. But you should consider replacing it with jakarta.mail instead.

In addition, replace every instance of javax.mail with jakarta.mail in your codebase.

Uzial answered 13/8, 2021 at 0:5 Comment(0)
T
0

It seems there were some issue in downloading artifacts from repo. yesterday. Today when I run mvn clean install it downloaded few artifacts which was not happening yesterday. I was shocked of seeing no error today. The artifacts got downloaded today from repo. and the jars were bringing javax.mail:mail:jar:1.4.1

Twopence answered 12/12, 2013 at 23:37 Comment(1)
Sometimes, the jars don't get loaded properly ... and I must say, after spending about an hour trying to figure out the issue, This gave me a clue as to what could have happened.European
D
0

Got this exception when I was using SpringBoot's starter mail that provides auto-configuration and starter module for Spring's JavaMailSender interface. I failed to provide the dependency in the correct gradle subproject.

To fix the exception make sure the "libraries.springBootStarterMail" dependency is provided.

Derringdo answered 18/2, 2019 at 3:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.