Here is my structure
\jpa
\src
\resources
\META-INF
\persistence.xml
\oldtests
\com
TestClass.java
\war
\oldtests
\com
TestSuite.java
TestClass extends BaseTest, and I am running it via the test suite.
In the test itself I am grabbing my persistance info with…
public class BaseTest extends TestCase {
protected EntityManagerFactory emf;
protected EntityManager em;
@Override
protected void setUp() throws Exception {
super.setUp();
emf = Persistence.createEntityManagerFactory("test");
em = emf.createEntityManager();
...
}
...
}
However, emf is always null, thus throwing an NPE on the next line. This leads me to believe my persistence.xml isn’t getting picked up for some reason. Can someone help me solve where the file needs to be located? Is there a place I can confirm it isn’t an issue with the file itself (bad configuration)?
I could add the persistance-unit on request but I doubt that is the issue since we are using this elsewhere. Also I am using eclipse to run my tests.
The steps I needed to solve this are follows:
Add IBM plugin jars to classpath
I did this by creating a user library that points to
<WASINSTALL>\plugins\*.jarAdd items to your Junit Classpath.
I did this by going to
run>Debug ConfigurationsNext I selected the junit test suite configuration
Next I selected the classpath tab
Finally I added the JPA project and the user lib using the advanced option.
This seeemed to solve my issue