0

Im working on ejb3 and testing with arqullian. I have following dependency in pom.xml

  <dependency>
        <groupId>org.glassfish.main.ejb</groupId>
        <artifactId>javax.ejb</artifactId>
    </dependency>

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
    </dependency>


    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.glassfish.main.extras</groupId>
        <artifactId>glassfish-embedded-all</artifactId>
        <version>3.1.2</version>
        <scope>test</scope>
    </dependency>

I need to exclude first two dependency while I'm running test case, but it will be available other than testing time.

How can achieve this ?

Any help is much appreciated.

A N M Bazlur Rahman
  • 2,280
  • 6
  • 38
  • 51

2 Answers2

0

I believe you can use the javaee-api dependency alone, since you can obtain the EJB APIs from it. You should specify it as a dependency with provided scope though, since it cannot be used for anything other than compiling your tests, and is provided at runtime by the container (in this case, embedded GlassFish).

If you run into troubles with the javaee-api, you could try using JBoss Java EE 6 APIs, since they do not contain any stripped down method bodies that are usually the source of the problem with the javaee-api dependency.

Vineet Reynolds
  • 76,006
  • 17
  • 150
  • 174
0

When you have Java EE 6 you need to have full Java EE API like Vineet writes instead of Java EE itself. For Java EE 7 the javaee-api dependency is enough to compile. But you need to have Java EE API to compile your code and it must have provided scope (It means that Maven uses it for compiling but does not add jars into archive because container provides them) scope for Java EE dependency and probably remove dependency for EJB.

Here is my working sample for JBoss and Java EE 7. These dependencies are enough to run Arqullian with embedded container:

<dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-arquillian-container-embedded</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-embedded</artifactId>
        <scope>test</scope>
    </dependency>

Here is the Dependency Management for Java EE 6 Specification APIs. I use it for Arqullian testing instead of javaee-api.

    <dependency>
        <groupId>org.jboss.spec</groupId>
        <artifactId>jboss-javaee-6.0</artifactId>
        <version>1.0.0.Final</version>
        <scope>provided</scope>
        <type>pom</type>
    </dependency>
Cyva
  • 1,057
  • 10
  • 9