0

您好,我尝试了一个应用程序,该应用程序用于使用 JPA 将我域中的前 100 个用户存储到表中。但它返回服务器错误。皮尔斯帮帮我。这是我试过的代码..

         public class AppsProvisioning {
       public String m[]=new String[1000];
  public int a;
  final EntityManager em = EMFService.get().createEntityManager();
//public static void main(String[] args)
 public void calluser() throws AppsForYourDomainException, ServiceException,    
  {

  try {

    // Create a new Apps Provisioning service
    UserService myService = new UserService("My Application");
    myService.setUserCredentials("admin@xxxx.edu.in","xxxxxxxx");

    // Get a list of all entries
    URL metafeedUrl = new URL("https://www.google.com/a/feeds/domain/user/2.0/");
    System.out.println("Getting user entries...\n");
    UserFeed resultFeed = myService.getFeed(metafeedUrl, UserFeed.class);
    List<UserEntry> entries = resultFeed.getEntries();
    for(int i=0; i<entries.size(); i++) {

      UserEntry entry = entries.get(i);
      m[i]=entry.getTitle().getPlainText();
      table greeting1 = new table(m[i]);
      em.persist(greeting1);
      System.out.println("\t" + entry.getTitle().getPlainText());
    }


    a=entries.size();
    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();
  }
  finally
  {    
   em.close();
  }
}

}

我认为 em.close() 错误中的错误是:服务器错误服务器遇到错误,无法完成您的请求。问候沙伦

4

1 回答 1

0

将提要网址 (https://www.google.com/a/feeds/domain/user/2.0/) 中的“域”替换为您的域“xxxx.edu.in”。

作为替代方案,请按照参考指南http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_reference_java.html中的说明使用 AppsForYourDomainClient.retrieveAllUsers()

于 2011-09-02T20:35:55.830 回答