I am using eclipse + eclipselink + maven2 + mysql + jpa 2.0 + java SE.
I can create MySQL tables from the Entity classes with Eclipse. The persistence.xml is in src/main/resources/META-INF/…
I also has database connections specified in eclipse for production and testing. Either one is chosen with the project and seems to work.
Depending which data source is used with the project, the tables are created to selected database. What is in the persistence.xml as database connection details is ignored (not sure what to expect). Also if I right click on the persistence.xml and select ‘JPA Tools’ > ‘Synchronize Class List’. The file gets updated with the entity classes.
The persistence.xml is also required or else the tables will not be created in either of the databases. (Tested by renaming the file)
Earlier I was also able to execute some DAO-methods for testing by putting in and loading stuff. Also there was a menu item in eclipse package explorer named ‘JPA’, listing the JPA entities in the project, which no longer exists.
I made no changes on the project (only closed the computer for night). The next time the project was opened, I was no longer able to perform any of the DAO-methods and I get the following error:
No Persistence provider for EntityManager named xxx
The same error comes for the main class having DAO-methods, JUnit test ran by Eclipse and the same tests executed by Maven.
Note: I am still able to create the tables from entities.
Any advice?
The problem was in the pom.xml.
I had the dependency for hibernate as eclipselink was needed.
WRONG: This is what I Had
RIGHT: It was suppose to be
I got the solution by purely testing everything possible. Not sure even how I managed to try the substitution as I was able to perform test with the same pom & project earlier.
None of the errors or how it was functioning did not suggest it could be somewhat wrong.
Not even sure that’s completely right, but at least it works again.