Issue
I met a issue when I was working on a EJB project, test code could not find javax.ejb.embeddable.EJBContainer of javaee-api. Because javaee-api was defined as provided scope in pom it's not possible to be accessed in test code classpath. In maven dependency definition,
compile | provided | runtime | test | system | import | |
---|---|---|---|---|---|---|
src compilation | Available | Available | Available | |||
src running | Available | Available | Available | Available | ||
test compilation | Available | Available | ||||
test running | Available | Available | Available |
*** import only could be used in <dependencyManagement> section.
Solution
Declare javaee-api as compile scope and meanwhile exclude it.
Modify the pom to following
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</exclusion>
</exclusions>
</dependency>