• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

No PersistenceProvider for EntityManager

 
Ranch Hand
Posts: 146
2
Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having issues trying to connect to a MySQL DB using JPA with EclipseLink as the provider. Also, I am trying to learn both Maven and IntelliJ IDEA so am not yet familiar with their features or how they work fully, which may be half of the issue. Anyway, I am trying to test that everything is set up correctly by adding a record to a table in the database, but get the following error:



And FlyingApp.java:



The database connection works fine since I generated my entities based on the database schema through running the JavaEE Persistence wizard on the main module. I then refactored the persistence unit name so it was no longer the default NewPersistenceUnit or whatever it was called. My persistence.xml:



I get an error on line 5 telling me that the class PersistenceProvider and the package jpa cannot be resolved. My project lib folder has the java.prsistence jar, but this does not contain the necessary class nor even the jpa sub-package.

It would seem that I have not done something correctly, or IntelliJ IDEA is not importing the correct library (I suspect the former to be more likely). I have tried to add a dependency to the Maven pom.xml, but can't work out how to do this through the IDE (the Cmd-N -> Generate Dependency option does not bring up any dependencies). Therefore, the pom.xml currently looks as follows:



Please can someone give me a shove in the right direction to sort this out?

Edit:

I have manually added the dependencies for eclipse link and jpa, although I don't understand why IntelliJ didn't do this for me:



This has removed the error in persistence.xml. However, the error still remains when I try to run the program. My project structure is as below:

reply
    Bookmark Topic Watch Topic
  • New Topic