5 Replies Latest reply on Jul 29, 2009 2:55 PM by 800339

    JPA, Hibernate and Oracle, a persistence problem

    800339

      Hello all:

      I just started to learn JPA persistence, trying to save a simple JOPO into a oracle XE table, and I came across a problem, like this:

      Exception in thread "main" javax.persistence.PersistenceException: No resource files named META-INF/services/javax.persistence.spi.PersistenceProvider were found. Please make sure that the persistence provider jar file is in your classpath. at javax.persistence.Persistence.findAllProviders(Persistence.java:167) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:103) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83) at com.entrepidea.java.jpa.PersistentDemo.main(PersistentDemo.java:13)

      after googling and I found the link: http://forums.sun.com/thread.jspa?threadID=5169272 and notice that I didn't have the hibernate-entitymanager.jar

      I added the jar but the problem didn't go away. Now it looks like this:

      0 [main] INFO org.hibernate.cfg.annotations.Version - Hibernate Annotations 3.4.0.GA 16 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA 16 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 16 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist 16 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling 78 [main] INFO org.hibernate.annotations.common.Version - Hibernate Commons Annotations 3.1.0.GA 78 [main] INFO org.hibernate.ejb.Version - Hibernate EntityManager 3.4.0.GA Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named CustomerService:  The following providers: org.hibernate.ejb.HibernatePersistence Returned null to createEntityManagerFactory. at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83) at com.entrepidea.java.jpa.PersistentDemo.main(PersistentDemo.java:13)

      my persistence.xml looks like this:

      <?xml version="1.0" encoding="UTF-8"?>  <persistence version="1.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_1_0.xsd">  <persistence-unit name="JPAService" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> <property name="hibernate.hbm2ddl.auto" value="update"/> <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/> <property name="hibernate.connection.username" value="hr"/> <property name="hibernate.connection.password" value="hr"/> <property name="hibernate.connection.url" value="jdbc:oracle:thin:@zodiac"/> </properties> </persistence-unit> </persistence>

      Did I still miss something?

      Thanks a lot!
      Sway