初始SessionFactory创建失败。javax.persistence.PersistenceException

初始SessionFactory创建失败。javax.persistence.PersistenceException,java,jsp,jpa,eclipselink,Java,Jsp,Jpa,Eclipselink,我正在做web应用程序。我发现许多问题都有相同的问题 但我没有得到正确的答案。我的文件夹结构和类路径都是正确的,但我不知道为什么会发生这种异常 下面是我的文件夹结构。这里persistence.xml文件位于src文件夹的META-INF文件夹中 My persistence.xml: <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSche

我正在做web应用程序。我发现许多问题都有相同的问题

但我没有得到正确的答案。我的文件夹结构和类路径都是正确的,但我不知道为什么会发生这种异常

下面是我的文件夹结构。这里persistence.xml文件位于src文件夹的META-INF文件夹中

My persistence.xml:

<persistence xmlns="http://java.sun.com/xml/ns/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_1_0.xsd"
version="1.0">
  <persistence-unit name="jspWithJpa" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>com.entity.Student</class>
    <properties>    
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/reports" />
      <property name="javax.persistence.jdbc.user" value="root" />
      <property name="javax.persistence.jdbc.password" value="root" />
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
    </properties>
  </persistence-unit>
</persistence>
例外情况是:

Initial SessionFactory creation failed.javax.persistence.PersistenceException: No   Persistence provider for EntityManager named jspWithJpa
Mar 2, 2014 11:16:08 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [com.action.InsertData] in context with path   [/jspWithJpa] threw exception [Servlet execution threw an exception] with root cause
javax.persistence.PersistenceException: No Persistence provider for EntityManager named jspWithJpa

将提供者标记更改为in
persistence.xml
为:

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
org.eclipse.persistence.jpa.PersistenceProvider

从您的LIB中,我可以看到您使用eclipselink作为JPA提供程序,而不是hibernate。

您的persistence.xml文件在META-INF中?@Koitoer我在META-INF中有persistence.xml文件非常感谢@Camilo Bermúdez问题已经解决
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>