<p>I'm trying to load test data into a test DB during a maven build for integration testing. persistence.xml is being copied to <code>target/test-classes/META-INF/</code> correctly, but I get this exception when the test is run.</p>

<blockquote>
  <p>javax.persistence.PersistenceException:
  No Persistence provider for
  EntityManager named aimDatabase</p>
</blockquote>

<p>It looks like it's not finding or loading persistence.xml.</p>

[{'answer_id': 78643, 'author': 'kbaribeau', 'author_id': 8085, 'author_profile': 'https://Stackoverflow.com/users/8085', 'pm_score': 2, 'selected': False, 'text': '<p>If this is on windows, you can use sysinternal\'s procmon to find out if it\'s checking the right path.</p>\n\n<p>Just filter by path -> contains -> persistence.xml.  Procmon will pick up any attempts to open a file named persistenc.xml, and you can check to see the path or paths that get tried.</p>\n\n<p>See here for more detail on procmon: <a href="http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx" rel="nofollow noreferrer">http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx</a></p>\n'}, {'answer_id': 232105, 'author': 'stevemac', 'author_id': 20150, 'author_profile': 'https://Stackoverflow.com/users/20150', 'pm_score': 2, 'selected': False, 'text': "<p>I had the same problem and it wasn't that it couldn't find the persistence.xml file, but that it couldn't find the provider specified in the XML.</p>\n\n<p>Ensure that you have the correct JPA provider dependancies and the correct provider definition in your xml file.</p>\n\n<p>ie. <code>&lt;provider&gt;oracle.toplink.essentials.PersistenceProvider&lt;/provider&gt;</code></p>\n\n<p>With maven, I had to install the 2 toplink-essentials jars locally as there were no public repositories that held the dependancies.</p>\n"}, {'answer_id': 272176, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>we got the same problem, does some tweaking on the project and finaly find following \nproblem (more clear error description):\nat oracle.toplink.essentials.ejb.cmp3.persistence.\n  PersistenceUnitProcessor.computePURootURL(PersistenceUnitProcessor.java:248)</p>\n\n<p>With that information we recalled a primary rule:\nNO WHITE SPACES IN PATH NAMES!!!</p>\n\n<p>Try this. Works for us <em>smile</em>.\nMaybe some day this will be fixed.</p>\n\n<p>Hope this works for you. Good luck.</p>\n'}, {'answer_id': 1380292, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': "<p>I'm using Maven2, and I had forgotten to add this dependency in my pom.xml file:</p>\n\n<pre><code> &lt;dependency&gt;\n   &lt;groupId&gt;org.hibernate&lt;/groupId&gt;\n   &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;\n   &lt;version&gt;3.4.0.GA&lt;/version&gt;\n &lt;/dependency&gt; \n</code></pre>\n"}, {'answer_id': 2131109, 'author': 'jhumble', 'author_id': 217829, 'author_profile': 'https://Stackoverflow.com/users/217829', 'pm_score': 4, 'selected': False, 'text': '<p>Just solved the same problem with a Maven/Eclipse based JPA project.</p>\n\n<p>I had my META-INF directory under <code>src/main/java</code> with the concequence that it was not copied to the target directory before the test phase.</p>\n\n<p>Moving this directory to <code>src/main/resources</code> solved the problem and ensured that the <code>META-INF/persistence.xml</code> file was present in <code>target/classes</code> when the tests were run.</p>\n\n<p>I <em>think</em> that the JPA facet put my <code>META-INF/persistence.xml</code> file in <code>src/main/java</code>, which turned out to be the root of my problem.</p>\n'}, {'answer_id': 3212235, 'author': 'Nils Schmidt', 'author_id': 255036, 'author_profile': 'https://Stackoverflow.com/users/255036', 'pm_score': 2, 'selected': False, 'text': '<p>Is your persistence.xml located in scr/test/resources? Cause I was facing similar problems.</p>\n\n<p>Everything is working fine as long as my <strong>persistence.xml</strong> is located in <strong>src/main/resources</strong>. </p>\n\n<p>If I move <strong>persistence.xml</strong> to <strong>src/test/resources</strong> nothing works anymore. </p>\n\n<p>The only helpful but sad answer is here: <a href="http://jira.codehaus.org/browse/SUREFIRE-427" rel="nofollow noreferrer">http://jira.codehaus.org/browse/SUREFIRE-427</a></p>\n\n<p>Seems like it is not possible right now for unclear reasons. :-(</p>\n'}]
['https://Stackoverflow.com/questions/76591', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4893/']