我正在尝试让 eclipselink 与 GWT 的 requestfactory 一起工作。我不断收到以下错误:
Caused by: java.lang.RuntimeException: Server Error: No Persistence provider for EntityManager named default
在网上阅读,似乎persistence.xml必须存在于WEB-INF/classes/META-INF/中。我尝试在 src/META-INF 下创建一个文件夹并将 persistence.xml 放入其中,但是当我在 Eclipse 中构建项目时,它没有包含在 war/WEB-INF/classes/ 中。有什么建议么?我正在使用 GWT 2.3、EclipseLink 2.3 和 Eclipse 3.7。如何让 eclipse 将 persistence.xml 包含到正确的位置?
持久性.xml
<?xml version="1.0" encoding="UTF-8" ?> <persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="default" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.manning.gwtia.ch08.v2.server.Contact</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/example" />
<property name="javax.persistence.jdbc.user" value="" />
<property name="javax.persistence.jdbc.password" value="" />
<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>