求助,java Persistence provider问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了求助,java Persistence provider问题相关的知识,希望对你有一定的参考价值。

javax.persistence.PersistenceException: No Persistence provider for EntityManager named zlzx_mysql
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at org.zlzx.util.EntityTool.getEntityManager(EntityTool.java:27)
at org.zlzx.web.action.AbstractAction.<init>(AbstractAction.java:20)
at org.zlzx.web.action.ZlzxHomeAction.<init>(ZlzxHomeAction.java:27)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:131)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:162)
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:151)
at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:121)
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:300)
at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:400)
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)
......

下面是配置文件:
<persistence-unit name="zlzx_MYSQL" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.PersistenceProvider</provider>
<class>org.zlzx.common.Administrator</class>
<class>org.zlzx.common.UserAuthority</class>
<class>org.zlzx.common.WebsiteLink</class>
<class>org.zlzx.common.OrderableIssue</class>
<class>org.zlzx.common.PeriodicalPrice</class>
<properties>
<property name="toplink.jdbc.user" value="root"/>
<property name="toplink.jdbc.password" value="root"/>
<property name="toplink.jdbc.url" value="jdbc:mysql://211.71.30.95:3306/zlzx_db?useUnicode=true&characterEncoding=utf-8&autoReconnect=true"/>
<property name="toplink.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="toplink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>配置文件里的oracle.toplink.essentials.PersistenceProvider 所在的jar包存在啊,求教为什么提示找不到啊?

参考技术A 检查persistence.xml。
<persistence-unit name="***" transaction-type="RESOURCE_LOCAL">

提示说没找到我们申明的持久单元。
该行:
<provider>org.hibernate.ejb.HibernatePersistence</provider>
不存在于系统中,需要去hibernate网站
http://hibernate.org/30.html
下载Hibernate EntityManager import到工程中

注:
Hibernate 3.2以及以后的版本开始支持JPA,涉及JPA的子项目有三个,它们分别是:— Hibernate Core:Hibernate框架的核心实现。— Hibernate Annotations:支持JDK 5.0的注释。— Hibernate EntityManager:支持JPA的实现。
参考技术B 清除缓存试一下。本回答被提问者采纳 参考技术C 没有序列化

Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners

Answer: This seems to be caused by Hibernate 3.6. It is now dependent on JPA, so it must have a JPA jar in the class path as well. You can find one in the Hibernate 3.6 distro: hibernate-distribution-3.6.0.Final/lib/jpa/hibernate-jpa-2.0-api-1.0.0.Final.jar

以上是关于求助,java Persistence provider问题的主要内容,如果未能解决你的问题,请参考以下文章

java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;

java.lang.ClassNotFoundException: javax.persistence.EntityListeners

消息错误java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;

Caused by: java.lang.NoSuchMethodError: javax.persistencejavax.persistence.spi.PersistenceProvider

Java Persistence/ManyToMany

Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners