-->
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.  [ 6 posts ] 
Author Message
 Post subject: javax.persistence.PersistenceException: No Persistence provi
PostPosted: Wed Jul 19, 2006 3:09 pm 
Newbie

Joined: Wed Mar 08, 2006 8:11 am
Posts: 17
Location: Israel
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2.0.cr2

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Code:
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named dnd
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:41)
   at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
   at org.persistence.impl.Test.main(Test.java:17)


Name and version of the database you are using: MS-SQL Server 2005

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


I am just trying to open up an entityManager, as a start. I am sure my database properties aren't set right anyway, but I want to first get a different exception, to deal with it.

So far, my code is:
Code:
System.out.println(1);
      EntityManagerFactory entityManagerFactory = Persistence
            .createEntityManagerFactory("sample");
      System.out.println(2);
      EntityManager entityManager = entityManagerFactory
            .createEntityManager();
      System.out.println(3);
      entityManager.close();
      System.out.println(4);
      entityManagerFactory.close();
      System.out.println(5);



and my persistence.xml file is:

Code:
<persistence 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"
   version="1.0">
   <persistence-unit name="sample" transaction-type="RESOURCE_LOCAL">
      <provider>org.hibernate.ej.HibernatePersistence</provider>
      <properties>
         <property name="hibernate.dialect"
            value="org.hibernate.dialect.SQLServerDialect" />
         <property name="hibernate.connection.driver_class"
            value="hibernate.connection.driver_class" />
         <property name="hibernate.connection.url"
            value="jdbc:sqlserver://." />
         <property name="hibernate.connection.username" value="dnd" />
         <property name="hibernate.connection.password" value="dnd" />
         <property name="hibernate.hbm2ddl.auto" value="update" />
      </properties>
   </persistence-unit>
</persistence>


I have the ejb3-persistence.jar, hibernate-annotations.jar (3.2.0.CR1), hibernate-entitymanager.jar (3.2.0.CR1) files in my classpath as well, and am using eclipse 3.2 for win x64

I also put the META-INF folder as a source folder in my project. Figured it had to be, in order for the persistence.xml to get to the bin at the end.



Anyone here has any tip about it?


Top
 Profile  
 
 Post subject: Re: javax.persistence.PersistenceException: No Persistence p
PostPosted: Wed Jul 19, 2006 4:04 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
<provider>org.hibernate.ejb.HibernatePersistence</provider>

You are missing letter b.

noamg wrote:
I have the ejb3-persistence.jar, hibernate-annotations.jar (3.2.0.CR1), hibernate-entitymanager.jar (3.2.0.CR1) files in my classpath as well, and am using eclipse 3.2 for win x64


Where is Hibernate core?


Top
 Profile  
 
 Post subject: thanks for the quick reply
PostPosted: Wed Jul 19, 2006 4:41 pm 
Newbie

Joined: Wed Mar 08, 2006 8:11 am
Posts: 17
Location: Israel
but it wasn't it - I tried many times with and without the provider clause, and now I re-tried and got it right ("ejb"), but I am still getting the same exception as before.


Top
 Profile  
 
 Post subject: and about the second question
PostPosted: Wed Jul 19, 2006 4:44 pm 
Newbie

Joined: Wed Mar 08, 2006 8:11 am
Posts: 17
Location: Israel
yeah, I have hibernate3.jar in my classpath as well. sorry for not replying on it before.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 20, 2006 2:42 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Write in the right db properties.
Since that's the only place dnd is mentioned.
And we'll see if that's the problem - you know how it is with exceptions - not always we get the right info. ;-)


Top
 Profile  
 
 Post subject: thanks
PostPosted: Thu Jul 20, 2006 7:15 am 
Newbie

Joined: Wed Mar 08, 2006 8:11 am
Posts: 17
Location: Israel
But I figured out my first mistake this morning - I had to put META-INF inside my src folder, and not turn it into a source folder by itself. That only cause the persistence.xml to be copied to the bin/ folder, and not into bin/META-INF

Well, I bumped into another exception now, but I hadn't had time to look into it. Hope I'll figure it out myself.

thanks again.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.