1

嗨,当我在我的 gwt 项目上运行 RPC 方法时,我得到了这个异常,我不明白为什么......我使用 EclipseLink 和 HSQLDB

SEVERE: javax.servlet.ServletContext log: Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract void     
 it.project.client.service.EmployeeService.createemployees()' threw an unexpected  
exception:javax.persistence.PersistenceException: No persistence providers available for
"myPU" after trying the following discovered implementations:  
org.datanucleus.api.jpa.PersistenceProviderImpl
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:389)

这是电话: MyProject.java

    public class MyProject implements EntryPoint {  

     private final EmployeeServiceAsync aService = (EmployeeServiceAsync)             GWT.create(EmployeeService.class);

       @Override
       public void onModuleLoad() {

         aService.createemployee(new AsyncCallback<Void>() {
            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Creation Employees failed!");
            }
            @Override
            public void onSuccess(Void result) {
                Window.alert("Creation success!");
            }
        });

这是给出异常的方法: EmployeeService.java

package com.example.client.service;
  @RemoteServiceRelativePath("employeeService")
  public interface EmployeeService extends RemoteService{

  public void createemployee();
}

EmployeeServiceImpl.java

package com.example.server.ServiceImpl;
public class EmployeeServiceImpl extends RemoteServiceServlet implements EmployeeService              {

private static final long serialVersionUID = 1L;

public void createemployee() {

javax.persistence.EntityManagerFactory emf =      Persistence.createEntityManagerFactory("ronfPU");
javax.persistence.EntityManager em = emf.createEntityManager();


   try {
      // Create new Employee
      em.getTransaction().begin();
      Employee e1 = new Employee();
      e1.setName("admin");
      e1.setPassword("admin");
      em.persist(a1);
      em.getTransaction().commit();
   } 
   finally {
     em.close();
   }   
 }
}

这些是我的构建路径的 jar:

eclipselink.jar

gwt-servlet.jar

hsqldb.jar

javax.persistence_2.0.4.jar

持久性-api-sources-2.0.jar

smartgwt.jar

感谢您的帮助!

4

1 回答 1

0

该错误似乎表明您的类路径中没有 eclipselink.jar。

尝试一个简单的 Class.forName("org.eclipse.persistence.jpa.PersistenceProvider")

于 2013-07-17T13:49:17.733 回答