javax.persistence.PersistenceException: Invalid persistence.xml

后端 未结 4 1762
暗喜
暗喜 2021-01-14 17:22

I\'m working on project with Servlet,JPA,EJB and JBoss in eclipse. As you can see in the title of my topic I have an error on my persistence.xml file but I don\'t know whi

相关标签:
4条回答
  • 2021-01-14 17:43

    Unless you didn't copy-paste the complete file, the closing tag is missing. Append

    </persistence>
    

    in your persistence.xml

    EDIT

    It seems that the JNDI name of your datasource is wrong. Usually it starts with : java:/

    0 讨论(0)
  • 2021-01-14 17:47

    This error means the version of Hibernate that you're using doesn't support version="2.1" in persistence.xml. Change the version to 2.0 (and update the xsi:schemaLocation for clarity).

    0 讨论(0)
  • 2021-01-14 17:47

    Don't set a provider value.

    remove

    <provider>org.hibernate.ejb.HibernatePersistence</provider> 
    

    and try.

    0 讨论(0)
  • 2021-01-14 17:49

    switch to

    <persistence version="2.0" 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_2_0.xsd">
    
    0 讨论(0)
提交回复
热议问题