嗨,当我在我的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();
}
}
}
Thoose是我构建路径的罐子:
eclipselink.jar
GWT-的servlet.jar
的hsqldb.jar
javax.persistence_2.0.4.jar
持久性的API-源-2.0.jar
smartgwt.jar
感谢您的帮助!
答案 0 :(得分:0)
该错误似乎表明您的类路径中没有eclipselink.jar。
尝试一个简单的Class.forName(&#34; org.eclipse.persistence.jpa.PersistenceProvider&#34;)