I wrote a JUnit test case for JPA using spring. The testcase passes in eclips. But if I execute the same testcase using maven (mvn test) it fails.
My test case is :
It looks like you run in a Problem with the Java EE API package that contains only empty interfaces.
Replace
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
by:
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
More details can be found here.
I have solved this problem. The problem was mainly because of the dependency
<dependency>
<groupId>javaee</groupId>
<artifactId>javaee-api</artifactId>
<version>5</version>
<scope>provided</scope>
</dependency>
Actually this dependency was required for EJB so I placed this in my parent pom (and also in my testcases pom). Since my test case's pom had a parent depedency, by default it will be inherited. If you add this dependency then u must have a java EE container to run the program. Testcase does not require Java EE container.
Remove this dependency if you have the one in your pom file.
Have a look on Problem running unit tests from maven (JPA related) for more detail.