2

I found some solutions in the forum, but they not working for me. The problem is that when I run main method I receive this exception - image

PersistenceException: No Persistence provider for EntityManager

On the imane is my persistance.xml file pat but it's not working. I try to change file path to web/WEB-INF/classes/META-INF, but its's still not working.

Here my full persistance.xml source

<?xml version="1.0" encoding="UTF-8"?>

<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" version="2.1">

    <persistence-unit name="StudentPU">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>com.classes.StudentBean</class>
        <properties>
            <property name="hibernate.connection.url" value="jdbc:h2:tcp://localhost/~/Students"/>
            <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
            <property name="hibernate.connection.username" value="doncho"/>
            <property name="hibernate.connection.password" value=""/>
            <property name="hibernate.archive.autodetection" value="class"/>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hbm2ddl.auto" value="update"/>
            <property name="hibernate.temp.use_jdbc_metadata_defaults"
                      value="false" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
        </properties>
    </persistence-unit>
</persistence>

And one more thing? Why HibernatePersistence is stricken? I resolve "stricken" mistake like that - image Is it correct? But anyway the PersistenceException: No Persistence provider for EntityManager still there.

I tryed - this and this - nothings happened

I would be grateful for any ideas to resolve this error because @Entity method is important to me.

Best regards,

D. Balamjiev

Community
  • 1
  • 1
  • You can try to debug in class Persistence. There must be a reason, but I don't see it. – mm759 Nov 18 '16 at 18:20
  • "stricken" ?! You mean deprecated? Maybe because it has presumably been replaced with something else ... aka what deprecated means – Neil Stockton Nov 18 '16 at 18:32

1 Answers1

0

The workig method for me is to create this path in my project tree: web/WEB-INF/classes/META-INF/persistence.xml

This is working path when We create Web Applications with IntelliJ.