java.lang.NoClassDefFoundError: javax/mail/MessagingException

JBoss Issue Tracker | Agustin Treceno | 3 years ago
Do you know that we can give you better hits? Get more relevant results from Samebug’s stack trace search.
  1. 0

    I am trying to use the JBoss mail service with the following class: {code:java} import javax.annotation.Resource; import javax.mail.Address; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class SendMail2 { @Resource(mappedName = "java:jboss/mail/Default") private static Session mailSession; /** * @param args */ public static void main(String[] args) { try { MimeMessage m = new MimeMessage(mailSession); Address from = new InternetAddress(""); Address[] to = new InternetAddress[] { new InternetAddress("") }; m.setFrom(from); m.setRecipients(Message.RecipientType.TO, to); m.setSubject("JBoss AS 7 Mail"); m.setSentDate(new java.util.Date()); m.setContent("Mail sent from JBoss AS 7", "text/plain"); Transport.send(m); System.out.println("Mail sent!"); } catch (MessagingException e) { e.printStackTrace(); System.out.println("Error in Sending Mail: " + e); } } } {code} Then compile and execute the class using the jboss module loader: {noformat} $ javac -classpath /opt/jboss-eap-6.2/modules/system/layers/base/javax/mail/api/main/mail-1.4.5-redhat-1.jar ~/ $ /usr/java/jdk1.7.0_51/bin/java -jar jboss-modules.jar -mp modules -cp /home/agustin SendMail2 Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName( at at org.jboss.modules.Main.main( Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException from [Module "Classpath:main" from Class path module loader for path '/home/agustin'] at org.jboss.modules.ModuleClassLoader.findClass( at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked( at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked( at org.jboss.modules.ConcurrentClassLoader.performLoadClass( at org.jboss.modules.ConcurrentClassLoader.loadClass( ... 4 more {noformat} As you can see the ModuleClassLoader cannot find the class {{javax.mail.MessagingException}} which is in the javax.mail.api module. Now if I specify the JAR of that module in the classpath... it works! {noformat} $ /usr/java/jdk1.7.0_51/bin/java -jar jboss-modules.jar -mp modules -cp /home/agustin:/opt/jboss-eap-6.2/modules/system/layers/base/javax/mail/api/main/mail-1.4.5-redhat-1.jar SendMail2 Mail sent! {noformat} More info about the environment: {noformat} $ uname -a Linux mars 2.6.32-431.11.2.el6.x86_64 #1 SMP Mon Mar 3 13:32:45 EST 2014 x86_64 x86_64 x86_64 GNU/Linux $ cat version.txt JBoss Enterprise Application Platform - Version 6.2.0.GA $ bin/ -V ======================================================================================== To start a JBoss Enterprise Application Platform 6 Standalone Server, a single server instance, use the command: /opt/jboss-eap-6.2/bin/ To start a JBoss Enterprise Application Platform 6 Managed Domain, allowing control and management of multiple instances, use the command: /opt/jboss-eap-6.2/bin/ ======================================================================================== $ /usr/java/jdk1.7.0_51/bin/java -jar jboss-modules.jar -version JBoss Modules version 1.3.0.Final-redhat-2 {noformat}

    JBoss Issue Tracker | 3 years ago | Agustin Treceno
    java.lang.NoClassDefFoundError: javax/mail/MessagingException
  2. 0

    Vraptor 3 - Hibernate 4 | 2 years ago
    java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    Vraptor 3 - Hibernate 4 - Front-end - GUJ | 1 year ago
    java.lang.NoClassDefFoundError: org/hibernate/criterion/Criterion
  5. 0

    Problem deploying JBoss AS 7.1.0 - ClassNotFoundException

    Coderanch | 5 years ago | Rodrigo Sasaki
    javax.resource.ResourceException: Could not create connection

  1. Andreas Häber 1 times, last 1 week ago
  2. MoYapro 2 times, last 4 months ago
  3. Reich 8 times, last 5 months ago
  4. andyglick 1 times, last 6 months ago
  5. Cafecanudo 3 times, last 6 months ago
3 more registered users
75 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.ClassNotFoundException

    javax.mail.MessagingException from [Module "Classpath:main" from Class path module loader for path '/home/agustin']

    at org.jboss.modules.ModuleClassLoader.findClass()
  2. JBoss Modules
    1. org.jboss.modules.ModuleClassLoader.findClass(
    2. org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(
    3. org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(
    4. org.jboss.modules.ConcurrentClassLoader.performLoadClass(
    5. org.jboss.modules.ConcurrentClassLoader.loadClass(
    5 frames
  3. Java RT
    1. java.lang.Class.forName0(Native Method)
    2. java.lang.Class.forName(
    2 frames
  4. JBoss Modules
    2. org.jboss.modules.Main.main(
    2 frames