java - No Persistence provider for EntityManager named (Hibernate) -


i'm trying run sample jpa based project. error title time.

i looked here: no persistence provider entitymanager named

but found no working solution there.

here pom.xml:

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0"          xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"          xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">     <modelversion>4.0.0</modelversion>      <groupid>~path.example</groupid>     <artifactid>example</artifactid>     <version>1.0-snapshot</version>     <dependencies>          <dependency>             <groupid>mysql</groupid>             <artifactid>mysql-connector-java</artifactid>             <version>5.1.6</version>         </dependency>         <dependency>             <groupid>org.hibernate</groupid>             <artifactid>ejb3-persistence</artifactid>             <version>3.3.2.beta1</version>         </dependency>         <dependency>             <groupid>org.hibernate</groupid>             <artifactid>hibernate-entitymanager</artifactid>             <version>4.3.9.final</version>         </dependency>         <dependency>             <groupid>org.eclipse.jst.server.generic</groupid>             <artifactid>oc4j</artifactid>             <version>1.5.105-v200709061325</version>         </dependency>          <dependency>             <groupid>org.hibernate</groupid>             <artifactid>hibernate-core</artifactid>             <version>4.0.1.final</version>         </dependency>         <dependency>             <groupid>org.hibernate</groupid>             <artifactid>hibernate-validator</artifactid>             <version>4.2.0.final</version>         </dependency>         <dependency>             <groupid>org.hibernate.common</groupid>             <artifactid>hibernate-commons-annotations</artifactid>             <version>4.0.1.final</version>             <classifier>tests</classifier>         </dependency>         <dependency>             <groupid>org.hibernate.javax.persistence</groupid>             <artifactid>hibernate-jpa-2.0-api</artifactid>             <version>1.0.1.final</version>         </dependency>         <dependency>             <groupid>javax.validation</groupid>             <artifactid>validation-api</artifactid>             <version>1.0.0.ga</version>             <scope>provided</scope>         </dependency>         <dependency>             <groupid>org.slf4j</groupid>             <artifactid>slf4j-api</artifactid>             <version>1.6.4</version>         </dependency>         <dependency>             <groupid>org.jboss.logging</groupid>             <artifactid>jboss-logging</artifactid>             <version>3.1.0.cr2</version>         </dependency>         <dependency>             <groupid>org.slf4j</groupid>             <artifactid>slf4j-log4j12</artifactid>             <version>1.6.4</version>         </dependency>         <dependency>             <groupid>org.jboss.spec</groupid>             <artifactid>jboss-javaee-6.0</artifactid>             <version>1.0.0.final</version>             <type>provided</type>             <scope>pom</scope>         </dependency>         <dependency>             <groupid>junit</groupid>             <artifactid>junit</artifactid>             <version>4.11</version>             <scope>test</scope>         </dependency>         <dependency>             <groupid>org.jboss.arquillian.junit</groupid>             <artifactid>arquillian-junit-container</artifactid>             <scope>test</scope>         </dependency>         <dependency>             <groupid>org.jboss.spec</groupid>             <artifactid>jboss-javaee-6.0</artifactid>             <version>1.0.0.final</version>             <type>pom</type>             <scope>provided</scope>         </dependency>         <dependency>             <groupid>org.jboss.arquillian.container</groupid>             <artifactid>arquillian-weld-ee-embedded-1.1</artifactid>             <version>1.0.0.cr3</version>             <scope>test</scope>         </dependency>         <dependency>             <groupid>org.jboss.weld</groupid>             <artifactid>weld-core</artifactid>             <version>1.1.5.final</version>             <scope>test</scope>         </dependency>         <dependency>             <groupid>org.slf4j</groupid>             <artifactid>slf4j-simple</artifactid>             <version>1.6.4</version>             <scope>test</scope>         </dependency>     </dependencies>     <dependencymanagement>         <dependencies>             <dependency>                 <groupid>org.jboss.arquillian</groupid>                 <artifactid>arquillian-bom</artifactid>                 <version>1.1.8.final</version>                 <scope>import</scope>                 <type>pom</type>             </dependency>         </dependencies>     </dependencymanagement>  </project> 

it's possible have dependencies don't need. i'm inexperienced must admit, quite desperate , looked possible answer, , during process added dependencies may not used @ all.

here class supposed make entitymanager

package ~path.examples.service;  import ~path.examples.testjpa.domain.person;  import javax.persistence.*;  /**  * created me on 2015-04-22.  */ public class jpatest {     public static void main(string args[]) {         entitymanagerfactory entitymanagerfactory = persistence.createentitymanagerfactory("jpatest");         entitymanager em = entitymanagerfactory.createentitymanager();         entitytransaction usertransaction = em.gettransaction();          usertransaction.begin();         person person = new person();         person.setfirstname("charles");         person.setsurname("dickens");         em.persist(person);         usertransaction.commit();         em.close();         entitymanagerfactory.close();     } } 

also:

  1. im pretty sure files in appropriate locations, had problems me, seem have eliminated problem (other errors pop out before) :)

  2. it's obvious i'm missing, in advance help!

edit: it's problem lies in persistance.xml file, here (thanks pointing out). location of file src/main/resources/meta-inf

<?xml version="1.0" encoding="utf-8"?> <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">     <persistence-unit name="jpatest" transaction-type="resource_local">         <provider>org.hibernate.ejb.hibernatepersistence</provider>         <class>~path.examples.testjpa.domain.person</class>         <properties>             <property name="hibernate.show_sql" value="true" />             <property name="hibernate.format_sql" value="true" />             <property name="hibernate.dialect" value="org.hibernate.dialect.derbydialect" />             <property name="hibernate.hbm2ddl.auto" value="update" />         </properties>      </persistence-unit> </persistence> 

maybe didn't add hibernate jars project classpath? missing provider jars (in case hibernate) not show compile errors, required during runtime.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -