Andrew Martin Andrew Martin - 1 year ago 226
Java Question

Maven/Eclipse: Could not find any META-INF/persistence.xml file in the classpath

I know there are other questions on SO about this issue, but none of the solutions have worked for me. I'm using maven to build a java project in eclipse, and I have my persistence.xml file in the src/main/resource/META_INF folder. But when I try to mvn install, I always get this error:

No Persistence provider for EntityManager named plasma.persistence

Looking through the console output it appears to be caused by this:

[org.hibernate.jpa.boot.internal.PersistenceXmlParser] - HHH000318: Could not find any META-INF/persistence.xml file in the classpath

Here is my persistence.xml file:

<persistence xmlns=""
<persistence-unit name="plasma.persistence" transaction-type="RESOURCE_LOCAL">
<property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/>
<property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
<property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432:xxxxx"/>
<property name="hibernate.connection.username" value="xxxxx"/>
<property name="hibernate.connection.password" value="xxxxx"/>
<property name="hibernate.connection.pool_size" value="5"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.max_fetch_depth" value="5"/>
<property name="" value="update"/>

I have tried right clicking on the project and adding the META_INF folder to the build path, and it still doesn't work. Any ideas?

Answer Source

The proper home for the persistence file should be src/main/resources/META-INF. In the question, you mention src/main/resource/META_INF. Note, there should be an 's' in resources and a dash (-) in META-INF, not an underscore. Are those just typos in the question? If not, fix the path and it should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download