• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

spring - hibernate - jpa: no provider

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
I'm full of tinier men! And a tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!