Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFoundError: javax/activation/DataSource

Tags:

This is the code :

      Session session = Session.getDefaultInstance(props, null);       Store store = session.getStore("imaps");       store.connect("imap.gmail.com", "****@gmail.com", "****");       System.out.println(store);       Folder folder = store.getDefaultFolder();       folder = folder.getFolder("INBOX");       folder.open(Folder.READ_ONLY);        System.out.println("Message Count: "+folder.getMessageCount());       System.out.println("Unread Message Count: "+folder.getUnreadMessageCount());              Message[] messages = folder.getMessages();  --> here the code stops.        FetchProfile fp = new FetchProfile();       fp.add(FetchProfile.Item.ENVELOPE);       folder.fetch(messages, fp);        for (int i = 0; i< messages.length; i++)        {            System.out.println("From:"+ messages[i].getFrom());            } 

The code gives out the following excption and stops at the point shown.

Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource at com.google.code.com.sun.mail.imap.MessageCache.getMessage(MessageCache.java:129) at com.google.code.com.sun.mail.imap.IMAPFolder.getMessage(IMAPFolder.java:1394) at openReports.OpenReports.main

like image 447
RaviKiran Avatar asked Nov 18 '11 17:11

RaviKiran


2 Answers

In case you use maven you can add manually

<dependency>     <groupId>javax.activation</groupId>     <artifactId>activation</artifactId>     <version>1.1.1</version> </dependency> 
like image 132
jediz Avatar answered Oct 16 '22 10:10

jediz


I added activation.jar to buildpath and the problem is solved.

So i used 2 jars java-mail-ima.** .jar, activation.jar (for further referebces).

like image 42
RaviKiran Avatar answered Oct 16 '22 11:10

RaviKiran