Pages

Friday, May 21, 2010

Error in the Sample Code, Google Data Project

After installing the Google Data Plugin in Eclipse, when you create a new Google Data Project it gives you a list to select the API which you want to use. In my case I wanted to use the Google Documents API to export and import certain documents. Now when you proceed after selecting the locations of various JAR files, you get a sample Source Code that retrieves document entries from the account you specify.

This is the video for the installation of the Google Data Java Client Library, basically the plugin for the mentioned for eclipse.

This is a part of the sample code


  public class Documents {
  
    public static void main(String[] args) {
    
      try {
      
        // Create a new Documents service
        DocsService myService = new DocsService("My Application");
        myService.setUserCredentials(args[0],args[1]);
      
        // Get a list of all entries
        URL metafeedUrl = new URL("http://docs.google.com/feeds/documents/private/full");

Now this code wont run because of the error in the line:

URL metafeedUrl = new URL("http://docs.google.com/feeds/documents/private/full");

The Error is:


Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.(AltRegistry.java:100)
at com.google.gdata.client.Service.(Service.java:555)
at Documents.main(Documents.java:42)
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 4 more


This should be default. So the final corrected URL becomes,

URL metafeedUrl = new URL("http://docs.google.com/feeds/default/private/full");







No comments:

Post a Comment