• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

spring - hibernate - jpa: no provider

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I need some help with jpa configuration in spring.
I use spring, spring data and hibernate in the application. I have some problem with the configuration. It can create the tables in the database so this part works. But when I try to save a test object, I get an exception.

The spring uses this application-context.xml:




This is the exception what I get:

Error creating bean with name 'entityManagerFactory' defined in class path resource [application-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No PersistenceProvider specified in EntityManagerFactory configuration, and chosen PersistenceUnitInfo does not specify a provider class name either

I understand that the PersistenceProvider is missing but I don't know how to solve it.
I tried to find examples and follow them, but I couldn't solve it.

What is my mistake? How can I fix it?

Thank you

 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to put persistence.xml in META-INF directory, or you need to declare your PersistenceUnitManager in the spring xml
 
Gyorgy Pugymer
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI

I tried to follow your advice, but it is not absolutely clear for me. I still couldn't find a good example for it. Can I ask more help?
I don't use persistence.xml. I don't want to create more xml than absolutely necessary so I want to put this into the xml of spring.

Could you show me an example? Don't I have any possibility to put every configuration into the sesionFactory without the entityManagerFactory?

Thanks
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried going through the spring documentation for JPA here? THis shows you how to setup your EMF.

Since you are using Spring Data, you just have to declare the repositories xml tag to make it scan the class path for Spring Data repositories, and autowire the EMF into them.

You can look at the examples that Spring Data provides here , but all (I think) of these examples shy away from XML based configuration, and just use annotation driven configuration. The main example uses all defaults, so they don't provide anything in the configuration. All the do is put persistence.xml in classpath. Spring does all it's behind the scenes magic to create the EMF. Unfortunately, it doesn't help you understand how it really works.
 
reply
    Bookmark Topic Watch Topic
  • New Topic