• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

NoClassDefFoundError: javax/mail/Transportwhile exception sending email using javax.mail  RSS feed

 
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a class build for sending emails. But I am recieving the below exception when I am starting my class.



My program:

This is a maven project and the dependency I have used is :

I even verified the jars, mail-1.4.7.jar, activation-1.1.jar both the jars are present at classpath.
Anyone have any clue why I am receiving this excetion?
 
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably it is missing another jar file.

 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but which jar file? Maven installs all the dependencies.
 
Dana Ucaed
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I recomand to download the jar file and attach to the project.

Maybe be a problem with your local repositories.

Or you can close your project and reopen again.

 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tried both. but no luck.
 
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you also have to add the javaEE dependencie:

 
Sheriff
Posts: 21463
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've never needed EL to use JavaMail.
 
Daniel Demesmaecker
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I refer to my post from two weeks ago.
Adding the mentioned dependency solved my problem...
 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:you also have to add the javaEE dependencie:


Added. Updated the project, but still same issue :  Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Transport
I even verified for the javax.mail.Transport class in mail.jar, and it's present.
 
Daniel Demesmaecker
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please post your entire stacktrace
 
Daniel Demesmaecker
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is tested and working:

 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Daniel. Even the same code is working fine on my colleagues system.
Here is the stacktrace:
 
Daniel Demesmaecker
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know why you have two different sets of propperties or what's in "SPSAdapterProp.properties"
I tried to inport your code, but because I dont have the above mentioned proppertyfile, it dosn't work.
Anyway if the same code works on someone elses computer it has to be a dependency issue.
You manually added all the jars? Have you cleaned your project after?
 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried running your code as well, but the same issue.
For your code, I manually added the mail.jar and activation.jar on the classpath.
This is very strange, why only on my system the code is not working.
 
Daniel Demesmaecker
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When trying to run my code did you add the javaee-api dependency?
It has to be a dependency issue. Can I see your pom?
 
Daniel Demesmaecker
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way from java6 on, you don't need the activation.jar
 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:By the way from java6 on, you don't need the activation.jar


Yes it's by default under jdk.
Below is my pom file

And the snaphot of eclipse when running your code:
emailIssue.PNG
[Thumbnail for emailIssue.PNG]
 
Daniel Demesmaecker
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to displace the javax.mail and the javax-el dependencies with




 
Dana Ucaed
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must add the jar file as dependencies, not in classpath.

What editor did you use?

 
Daniel Demesmaecker
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dana Ucaed wrote:You must add the jar file as dependencies, not in classpath.

What editor did you use?


That has the same result, if you add the dependencies, maven automaticly downloads them and put them on your classpath...
It makes no difference if you download them and put them in your classpath or let maven do it
 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:Try to displace the javax.mail and the javax-el dependencies with



Still same issue. I am using eclipse. I am guessing something is wrong with my system or java. I will try to execute the same code on my other system.
 
Dana Ucaed
Ranch Hand
Posts: 451
6
Netbeans IDE Oracle Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please create another project without MAVEN and add the dependencies manual.

MAVEN created me the problems.

 
Rob Spoor
Sheriff
Posts: 21463
97
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Daniel Demesmaecker wrote:if you add the dependencies, maven automaticly downloads them and put them on your classpath...


But only for compiling, not for running applications (unless you do that through Maven).

That leaves a question for Puspender Tanwar: how do you start your program? Did you add the dependencies to the class path?
 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:But only for compiling, not for running applications (unless you do that through Maven).
That leaves a question for Puspender Tanwar: how do you start your program? Did you add the dependencies to the class path?


I am running the program from Eclipse itsef. All other dependencies are working properly.

Dana Ucaed wrote:Please create another project without MAVEN and add the dependencies manual.
MAVEN created me the problems.

Already tried. No change in error.
 
Daniel Demesmaecker
Rancher
Posts: 485
11
Hibernate IntelliJ IDE Java MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try running it on your other system?
could you post the SPSAdapterProp.properties, then I wil try to rebuild it on my computer
 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's running fine on my other system. Attaching the properties file. But it's very weird why it is failing on my this system.

 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sheriff
Posts: 23866
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Puspender Tanwar wrote:It's running fine on my other system. Attaching the properties file. But it's very weird why it is failing on my this system.



Does this mean that you have two systems where you're using Maven to generate something and then using Eclipse to run that something?
 
Puspender Tanwar
Ranch Hand
Posts: 626
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Does this mean that you have two systems where you're using Maven to generate something and then using Eclipse to run that something?


Yes exactly. And that something is behaving differently on both the systems. I am checking in and checking out the code from SVN. So no chance of code being different.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!