Pritam Banerjee Pritam Banerjee - 10 months ago 77
Java Question

Why do we need the following jboss jar for EJB 3.2 in Wildfly?

This might be a silly question. But I have a doubt, why do we need the following dependency to run EJB in Wildfly?

<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<scope>provided</scope>
</dependency>


Do we have something similar which is customizes for Wildfly?

Answer Source

Actually, you just need this maven dependency so your code can compile successfully during maven compile phase. For example, EJB annotations such as @Stateless are provided by it.

I use to declare this maven dependency instead for my Java EE 7 projects, so the whole bunch of JEE specs are available :

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

Finally this maven dependency has to be declared with "provided" scope as you don't need it within your package. Indeed it is already provided by Wildfly, as described in this documentation: Implicit module dependencies for deployments