尝试以下发现的实现后,没有可用于“myDB”的持久性提供程序
Posted
技术标签:
【中文标题】尝试以下发现的实现后,没有可用于“myDB”的持久性提供程序【英文标题】:No persistence providers available for "myDB" after trying the following discovered implementations 【发布时间】:2013-07-16 15:32:20 【问题描述】:您好,当我在我的 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
persistence-api-sources-2.0.jar
smartgwt.jar
感谢您的帮助!
【问题讨论】:
【参考方案1】:该错误似乎表明您的类路径中没有 eclipselink.jar。
尝试一个简单的 Class.forName("org.eclipse.persistence.jpa.PersistenceProvider")
【讨论】:
[ERROR]- 第 40 行:对于 Class 类型的方法 forName(String) 未定义...这应该是什么意思?以上是关于尝试以下发现的实现后,没有可用于“myDB”的持久性提供程序的主要内容,如果未能解决你的问题,请参考以下文章