【问题标题】:Provisioning Api using Java使用 Java 配置 API
【发布时间】:2010-06-02 08:36:16
【问题描述】:

您好,我尝试了一个应用程序,该应用程序用于使用 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() 中的错误 错误是:服务器错误 服务器遇到错误,无法完成您的请求。 问候 沙润

【问题讨论】:

  • 有助于显示代码中的哪一行导致此错误。

标签: java api jpa provisioning


【解决方案1】:

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

作为替代方案,使用 AppsForYourDomainClient.retrieveAllUsers(),如参考指南 http://code.google.com/googleapps/domain/gdata_provisioning_api_v2.0_reference_java.html 中所述

【讨论】:

    猜你喜欢
    • 2011-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-15
    • 2018-10-03
    • 2021-03-22
    • 2012-11-11
    • 1970-01-01
    相关资源
    最近更新 更多