aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Standalone JPA example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Standalone JPA example" Watch "Standalone JPA example" New topic
Author

Standalone JPA example

subir rastogi
Greenhorn

Joined: Apr 11, 2006
Posts: 18

Hi,
I am trying to create a simple JPA example using Java SE 5, Hibernate and MySQL.
I have created a persistence.xml and entity classes but when I run the example, I got the error-


Persistence.xml


Please let me know what is wrong with persistence.xml.

Thanks.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Did you put the persistence.xml file in your META-INF directory ? Is this directory in your CLASSPATH ?


[My Blog]
All roads lead to JavaRanch
subir rastogi
Greenhorn

Joined: Apr 11, 2006
Posts: 18
Yes, persistence.xml is in the classpath.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

is META-INF in the classpath ?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

I haven't played with standalone JPA much, but shouldn't that persistence.xml have an persistence-provider element which points to the Hibernate persistence provider class? Also posting the entire exception stacktrace might also help.


[My Blog] [JavaRanch Journal]
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Jaikiran Pai wrote:I haven't played with standalone JPA much, but shouldn't that persistence.xml have an persistence-provider element which points to the Hibernate persistence provider class?

Indeed, but if memory serves it's called "<provider>", not "persistence-provider" (unless things have changed since JPA 1.0). You'll also need "<class>" elements for all the classes that should be managed by JPA.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10102
    
165

Lester Burnham wrote:
but if memory serves it's called "<provider>", not "persistence-provider"

Indeed (even in JPA2).
subir rastogi
Greenhorn

Joined: Apr 11, 2006
Posts: 18
If I have to add provider class, in case of hibernate, how to find which is the jpa provider class?

thanks
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
The Hibernate documentation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Standalone JPA example