-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Entity Manager: No Persistence provider
PostPosted: Fri Aug 15, 2008 8:29 am 
Newbie

Joined: Fri Aug 15, 2008 7:18 am
Posts: 5
Hibernate version:
hibernate-3.2
hibernate-annotations-3.3.1.GA
hibernate-entitymanager-3.3.2.GA

Mapping documents:


Full stack trace of any exception that occurs:
Initial EntityManagerFactory creation failed.javax.persistence.PersistenceException: No Persistence provider for EntityManager named manager1

Name and version of the database you are using:
PostGreSQL Database Server 8.3

I want to have a simple Eclipse RCP Application to access the Database, i am surely missing a detail, cause im still very new to using Hibernate.

I read some Forums and most suggestions say some Jars are missing. I put all Jars i could find in hibernate core, annotations and entity manager into one Plug-In(using "create Plug-In from JAR Files") and added the Plug-In to the Dependencies of the RCP.
List of JARs in the Plug-In:
xml-apis.jar
ant-1.6.5.jar
ant-antlr-1.6.5.jar
ant-junit-1.6.5.jar
ant-launcher-1.6.5.jar
antlr-2.7.6.jar
ant-swing-1.6.5.jar
asm.jar
asm-attrs.jar
c3p0-0.9.1.jar
cglib-2.1.3.jar
checkstyle-all.jar
cleanimports.jar
commons-collections-2.1.1.jar
commons-logging-1.0.4.jar
concurrent-1.3.2.jar
dom4j-1.6.1.jar
ehcache-1.2.3.jar
ehcache-1.2.jar
ejb3-persistence.jar
hibernate3.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-entitymanager.jar
hsqldb-1.8.0.1.jar
ivy-1.4.1.jar
jaas.jar
jacc-1_0-fr.jar
javassist-3.1.jar
javassist.jar
jaxen-1.1-beta-7.jar
jboss-archive-browsing-5.0.0alpha-200607201-119.jar
jboss-cache.jar
jboss-common.jar
jboss-jmx.jar
jboss-system.jar
jgroups-2.2.8.jar
jta.jar
junit-3.8.1.jar
oscache-2.1.jar
persistence.jar
postgresql-8.3-603.jdbc2.jar
postgresql-8.3-603.jdbc2ee.jar
postgresql-8.3-603.jdbc3.jar
postgresql-8.3-603.jdbc4.jar
proxool-0.8.3.jar
swarmcache-1.0rc2.jar
syndiag2.jar
versioncheck.jar
xerces-2.6.2.jar

I put persistence.xml into META-INF of the RCP.
Looks like this
Code:
<?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="manager1" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>
      <class>entities.Address</class>
      <properties>         
         <property name="hibernate.dialect"               value="org.hibernate.dialect.PostgresSQLDialect" />
         <property name="hibernate.connection.driver_class"    value="org.postgresql.Driver"/>
         <property name="hibernate.connection.url"         value="jdbc:postgresql://localhost:5432/TestDB"/>
         <property name="hibernate.connection.username"      value="<User>"/>
         <property name="hibernate.connection.password"       value="<PW>" />
         <property name="hibernate.max_fetch_depth"          value="7" />

         <!--  debug properties -->
         <property name="hibernate.hbm2ddl.auto"          value="create-drop"/>
         <property name="hibernate.show_sql"             value="true"/>
      </properties>
   </persistence-unit>
</persistence>


Exception occurs in line ".createEntityManagerFactory(...)":
Code:
private static final EntityManagerFactory entityManagerFactory;
   
   static {
      try {
         // Create the EntityManagerFactory
         entityManagerFactory = Persistence.createEntityManagerFactory("manager1", new Properties());
      } catch (Throwable e) {
         // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial EntityManagerFactory creation failed." + e);
            throw new ExceptionInInitializerError(e);
      }
   }


I want to map a single Class called "Adress":
Code:

@Entity
public class Address implements Comparable<Address>, Cloneable, Serializable {

   private static final long serialVersionUID = 1L;

   private Long id;

   private String city;
   private String country;
   private String street;
   private String zip;
   
   /**
    * @return the id
    */
   @Id @GeneratedValue
   public Long getId() {
      return id;
   }
   


The calling class looks like this:
Code:
/**
    * Application boot trap
    * @param args
    */
   public static void main(String[] args) {

      // setup log4j logging facility
      try {
         SimpleLayout layout = new SimpleLayout();
         ConsoleAppender consoleAppender = new ConsoleAppender( layout );
         logger.addAppender( consoleAppender );
         FileAppender fileAppender = new FileAppender( layout, "logfile.log", false );
         logger.addAppender( fileAppender );
         logger.setLevel( Level.DEBUG );
      } catch( Exception ex ) {
         System.out.println( ex );
      }

      // run DB Test DBTest
      new DBTest().run();

public void run() {

      // store Address object
      Address address = new Address();
      
        address.setCity("Stuttgard");
      address.setCountry("Germany");
      address.setStreet("Waldweg 45");
      address.setZip("58421");
      
      saveAddress(address);
/**
    * Store an address object.
    * @param address
    */
   private void saveAddress(final Address address) {

      EntityManager     em = HibernateUtil.getEntityManager();
      EntityTransaction tx = em.getTransaction();
      
      tx.begin();
      em.merge(address);
      tx.commit();
      
      em.close();
   }


I just have the question wich point i'm missing or if there are any hints or known problems...

excuse me for the long post, i just wanna give all necessary information.

with beste regards
Nebelritter


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 19, 2008 12:11 pm 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

I have no experience with Eclipse RPC applications, but it might be a classloading issue when developing these type of applications.

See http://forum.hibernate.org/viewtopic.php?t=947805 or http://hibernate.org/311.html. Maybe this guides you into the right direction.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 4:48 pm 
Newbie

Joined: Thu Aug 28, 2008 4:17 pm
Posts: 1
1) make folder resources/META-INF
2) place file persistence.xml into this folder
3) add folder resources to classpath

btw, there is mistype in Hiberate Dialect, correct dialect for PostgreSQL is "org.hibernate.dialect.PostgreSQLDialect"


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 28, 2008 4:31 am 
Newbie

Joined: Fri Aug 15, 2008 7:18 am
Posts: 5
*Update

figured out the problem:
It was indeed a class loading issue that could be solved by registering to the buddy loader.

In the META-INF/manifest.MF of the generated Hibernate-PlugIn i used Eclipse-BuddyPolicy:registered and in the using PlugIn i registered the Hibernate-PlugIn via Eclipse-RegisterBuddy:<PlugInName>

Maybe something was even wrong with the re-/exported packages..

Thanks a lot anyways


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.