I have my persistence.xml
with the same name using TopLink
under the META-INF
directory.
Then, I have my code calling it with:
Mine got resolved by adding info in persistence.xml e.g. <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
and then making sure you have the library on classpath e.g. in Maven add dependency like
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.0</version>
</dependency>
There is another point: If you face this problem within an Eclipse RCP environment, you might have to change the Factory generation from Persistence.createEntityManagerFactory
to new PersistenceProvider().createEntityManagerFactory
see ECF for a detailed discussion on this.
If you are using Eclipse make sure that exclusion pattern does not remove your persistence.xml
from source folders on build path.
MyProject/src/main/java -> Excluded: <your_pattern>
Excluded: (None)
by selecting the node and clicking Edit... button on the left.Had the same issue, but this actually worked for me :
mvn install -e -Dmaven.repo.local=$WORKSPACE/.repository.
NB : The maven command above will reinstall all your project dependencies from scratch. Your console will be loaded with verbose logs due to the network request maven is making.
I just copied the META-INF into src and worked!
Verify the peristent unit name
<persistence-unit name="com.myapp.model.jpa"
transaction-type="RESOURCE_LOCAL">
public static final String PERSISTENCE_UNIT_NAME = "com.myapp.model.jpa";
Persistence.createEntityManagerFactory(**PERSISTENCE_UNIT_NAME**);