Solved

java.lang.ClassNotFoundException

Posted on 2012-04-02
3
448 Views
Last Modified: 2012-04-23
I am getting  this exception even if I have exactly same top level public class name and the filename.


The  exception is:
Exception in thread "Main Thread" java.lang.NoClassDefFoundError:
...../common/util/email/PostEmail
Caused by: java.lang.ClassNotFoundException: com.breeze.common.util.email.PostEmail
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)




And the class def is:
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class PostEmail {

.......


public static void main(String[]args){
//class is instantiated and used here
}

}

Any help is appreciated!
Thanks
0
Comment
Question by:addisuc
  • 2
3 Comments
 
LVL 35

Expert Comment

by:mccarl
ID: 37798788
> Caused by: java.lang.ClassNotFoundException: com.breeze.common.util.email.PostEmail

It is looking for PostEmail to be in a package, and so you must have a line in your class def to say that it is in this package. So add the following line to the top of your PostEmail.java file...
package com.breeze.common.util.email;

Open in new window

0
 

Author Comment

by:addisuc
ID: 37801904
I already had that package import but issue was caused by some other(unknown). I just recreated my clearcase view and issue goes away.
0
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 37804282
> I already had that package import

It's not an "import" but a package declaration. You say that you already had it then you must have removed it (or not copied it) in what you posted in your original question, so that is why I said to use it.


> I just recreated my clearcase view and issue goes away.

Glad your issue is resolved!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Adoquery sql  left join does not work 25 104
Advice on Xojo as a development tool over VB. 4 81
iSeries email authority 6 87
convert Systemjs to Webpack 3 73
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question