2009-11-08 4 views
1

eclipse 용 Google 데이터 API 플러그인을 다운로드했습니다. 성공적으로 컴파일지고 연락처 템플릿 (Demo.java)Google 데이터 API에서 연락처 데모를 실행하는 동안 런타임 예외

/* INSTRUCTION: This is a command line application. So please execute this template with the following arguments: 

     arg[0] = username 
     arg[1] = password 
*/ 

/** 
* @author (Your Name Here) 
* 
*/ 

import com.google.gdata.client.contacts.ContactsService; 
import com.google.gdata.data.contacts.ContactEntry; 
import com.google.gdata.data.contacts.ContactFeed; 
import com.google.gdata.util.AuthenticationException; 
import com.google.gdata.util.ServiceException; 

import java.io.IOException; 
import java.net.MalformedURLException; 
import java.net.URL; 
import java.util.List; 

/** 
* This is a test template 
*/ 

    public class Contacts { 

    public static void main(String[] args) { 

     try { 

     // Create a new Contacts service 
     ContactsService myService = new ContactsService("My Application"); 
     myService.setUserCredentials(args[0],args[1]); 

     // Get a list of all entries 
     URL metafeedUrl = new URL("http://www.google.com/m8/feeds/contacts/"+args[0]+"@gmail.com/base"); 
     System.out.println("Getting Contacts entries...\n"); 
     ContactFeed resultFeed = myService.getFeed(metafeedUrl, ContactFeed.class); 
     List<ContactEntry> entries = resultFeed.getEntries(); 
     for(int i=0; i<entries.size(); i++) { 
      ContactEntry entry = entries.get(i); 
      System.out.println("\t" + entry.getTitle().getPlainText()); 
     } 
     System.out.println("\nTotal Entries: "+entries.size()); 
     } 
     catch(AuthenticationException e) { 
     e.printStackTrace(); 
     } 
     catch(MalformedURLException e) { 
     e.printStackTrace(); 
     } 
     catch(ServiceException e) { 
     e.printStackTrace(); 
     } 
     catch(IOException e) { 
     e.printStackTrace(); 
     } 
    } 
    } 

을 처리하지만,이 런타임 예외를 던지는 동안 (내가 인수로 올바른 필요한 자격 증명을 제공하고있다).

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 Contacts.main(Contacts.java:36) 
Caused by: java.lang.ClassNotFoundException: com.google.common.collect.Maps 
    at java.net.URLClassLoader$1.run(Unknown Source) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) 
    at java.lang.ClassLoader.loadClass(Unknown Source) 
    at java.lang.ClassLoader.loadClassInternal(Unknown Source) 
    ... 4 more 

확실한 것은 무엇인가 놓치고 있지만 해결할 수 있습니다.

답변

1

종속성이 누락 된 것 같습니다. 이 google-collections을 다운로드하고 빌드 경로에 항아리를 추가하십시오.

+0

고맙습니다. 지터 :-), 이제 상황이 좋아질 것입니다. 그러나이 것은 GD-API 페이지 (google-collect-1.0-rc3.jar를 명시 적으로 설치해야 함)에 언급되어 있지 않습니다. – mogli

+0

그런 다음 문제를 해결하기 위해 버그 보고서를 발행하십시오. – jitter

관련 문제