Reputation: 1696
I'm trying to get a list of videos by a certain user using the YouTube Java GData library/API.
However, when I try to create a service by using YouTubeService service = new YouTubeService("Cyphon-MyCampusPulse-1", YOUTUBE_API_KEY);
, I get the following runtime exception:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
at scrapers.YouTubePulseScraper.<init>(YouTubePulseScraper.java:37)
at scrapers.YouTubePulseScraper.main(YouTubePulseScraper.java:153)
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 2 more
I'm not sure how the exception relates to what I'm doing. Any hints are appreciated.
Upvotes: 4
Views: 2119
Reputation: 54935
You need Java Mail, which is available from Maven Repository:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>
Upvotes: 0
Reputation: 7826
You need to add the JavaMail jar to your classpath, which contains javax.mail.MessagingException. You can get it here: http://www.oracle.com/technetwork/java/index-138643.html
Edit: Extracted from the documentation:
The GData Java Client Library has the following external dependencies. The following sections will describe how to install these dependencies on your favorite operating system (or the OS that you're stuck with at work).
- JDK (Java Development Kit) version 1.5+
- Apache Ant version 1.7+
- mail.jar in Sun's JavaMail API 1.4+
- activation.jar in Sun's JavaBeansActivationFramewrok. This is only required for media specific APIs including Document List Data API, Picasa Web Album API, and YouTube Data API.
- servlet.jar in Sun's Servlet API version 2.3+. This is required only if executing code samples in 'sample.authsub' or 'sample.gbase.recipe' packages.
A few of the .jar dependencies are only required for specific samples, but to avoid build errors, it's best just to get everything. Choose your operating system of choice to continue: Windows, Mac OS X, or Linux.
I've added this since if you're missing one dependency you might be missing others, so you should double check you have everything.
Upvotes: 7