2010-06-02 52 views
0

您好,我尝试了一个应用程序,它用于将我的域中的First 100用户存储到使用JPA的表中,但它返回的Server Error。 Pealse帮助我。 这是我试过的代码..使用Java的Provisioning Api

  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("[email protected]","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() 错误是:服务器错误 服务器遇到错误,无法完成您的请求。 Registers Sharun

+0

中说明可能是有帮助的显示哪些线在代码导致这个错误。 – 2010-06-02 08:46:21

+1

发布堆栈跟踪 – crowne 2010-06-02 09:08:54

回答