我正在将我的web-app从Glassfish 4迁移到Tomcat 7.当我尝试运行它时,我收到以下错误:PersistenceException:没有EntityManager的持久性提供程序。我的应用程序使用EclipseLink
我用这种方式修改了我的persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="com.cisco_OnePK_Web_war_1.0PU" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/one_pk" />
<property name="javax.persistence.jdbc.user" value="alex"/>
<property name="javax.persistence.jdbc.password" value="alex21"/>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.ddl-generation.output-mode" value="datab"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
这是我的context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/oneweb">
<Resource name="jdbc/one_pk" auth="Container"
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost:5432/one_pk"
username="alex" password="alex21" maxActive="20" maxIdle="30"
maxWait="-1"/>
</Context>
和web.xml:
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<resource-ref>
<description>postgreSQL Datasource example</description>
<res-ref-name>jdbc/one_pk</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>