-->
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.  [ 3 posts ] 
Author Message
 Post subject: javax.persistence.PersistenceException:
PostPosted: Mon Jun 12, 2006 8:15 pm 
Newbie

Joined: Mon Nov 28, 2005 12:43 am
Posts: 9
Thanks in advance for any help. I am trying to use JEE 5 Persistence, but I can't get my j2se app to run.

I am using:
Hibernate Core 3.2, Hibernate Annotations 3.2 CR1, and Hibernate EntityManager 3.2 CR1.

The error:
javax.persistence.PersistenceException: No Persistence provider for EntityManager named sample

The code:
factory = Persistence.createEntityManagerFactory("sample");
manager = factory.createEntityManager();

persistence.xml is in META-INF in the bin folder. bin is in the classpath.

ClassLoader.getSystemResource("META-INF/persistence.xml");
works fine.

Contents of persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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/ ... ce_1_0.xsd"
version="1.0">

<persistence-unit name="sample" transaction-type="RESOURCE_LOCAL">
<class>rgc.Person</class>
<properties>
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.username"
value="root"/>
<property name="hibernate.connection.password"
value="z8pp8lin"/>
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost/hibtest"/>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.hbm2ddl.auto"
value="update"/>
</properties>

</persistence-unit>

</persistence>


Thanks again for ay advice....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 14, 2006 2:08 pm 
Newbie

Joined: Mon Nov 28, 2005 12:43 am
Posts: 9
I was going to step through the source code, but I cannot find the source for Persistence.createEntityManagerFactory()? I assume it is in ejb3-persistence.jar. I am sure it ends up calling hibernate EntityManager, for which I do have the source.

What is the easiest way to get the source for ejb3-persistence.jar?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 14, 2006 5:36 pm 
Newbie

Joined: Mon Nov 28, 2005 12:43 am
Posts: 9
Well I figured it out. It was my own deployment mistake.

I found the source for ejb3-persistence.jar at glassfish. After perusing the source for Persistence.createEntityManagerFactory, I realized that ejb3-persistence.jar provides an abstraction layer above hibernate. This enables various persistence providers to be used. The provider class names should be in META-INF/services.

At this point I realized there was no jar in my classpath with META-INF/services. What I had done was copy the lib directory from hibernate-entitymanager-3.2.0.CR1 and forgot hibernate-entitymanager.jar in the root!

Note that this is NOT found at compile time. All you need to compile is ejb3-persistence.jar. hibernate-entitymanager.jar is only required to run.

I am posting this in the hopes of helping any other poor soul, like myself, from subjecting themselves to their own ineptitude.

;-)


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