views:

261

answers:

2

I am just trying to get some things to work so I can try some of google app engines java. However I seem to have a problem with something that I can't get a hold of.

The java code looks like this:

import java.net.URL;
import com.google.gdata.client.photos.*;
import com.google.gdata.data.photos.*;

public class TestPicasa {

public static void main(String[] args) {

 try {
  PicasawebService service = new PicasawebService("Picasa test");
  service.setUserCredentials("[email protected]", "password");
  URL feedURL = new URL("http://picasaweb.google.com/data/feed/api/user/username?kind=album");
  UserFeed feed = service.getFeed(feedURL, UserFeed.class);
  for (AlbumEntry entry : feed.getAlbumEntries()) {
    System.out.println(entry.getTitle().getPlainText());
  }
 } catch (Exception e) {
  e.printStackTrace();
 }

}

}

I have referenced to mail.jar, activation.jar, servlet-api.jar, gdata-client, gdata-client-meta, gdata-core, gdata-media, gdata-photos-2.0.jar and gdata-photos-meta-2.0.jar according to instruction from google.

And I get this error to the console:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/collect/Maps
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:118)
at com.google.gdata.wireformats.AltRegistry.<init>(AltRegistry.java:100)
at com.google.gdata.client.Service.<clinit>(Service.java:532)
at TestPicasa.main(TestPicasa.java:10)

Any idea on what I have missed?

A: 

Verify that you are not loading your google jars twice. Sometimes you would have 2 locations and the one that you are not thinking about would have a missing jar. Then your class file gets missing since the jar it's on is not under 1st classloader. This happens often on Tomcat when you have all your jars in the webapp's WEB-INF/lib but some of the jars in the Tomcat/lib. Alternatively, I only found missing class in google-collect.jar and I don''t think you are listing it

DroidIn.net
+1  A: 

You also need Google Collections

Schildmeijer