1
votes

I followed some tutorials on EJB 3.1 and those were using the following dependency for EJB-API.

    <dependency>
        <groupId>org.jboss.spec.javax.ejb</groupId>
        <artifactId>jboss-ejb-api_3.1_spec</artifactId>
        <version>1.0.2.Final</version>
    </dependency>

My problem is, this is only for jboss or can I used this in any other application servers. If not why there are dependency like these which are not independent from the application server it gets deployed. And also I found this reference for ejb 3.1 api. Therefore please elaborate what are these and why those are there.

2

2 Answers

2
votes

You can use it on any server you like. Just remember to put add the <scope>provided</scope> tag to the dependency like this:

<dependency>
        <groupId>org.jboss.spec.javax.ejb</groupId>
        <artifactId>jboss-ejb-api_3.1_spec</artifactId>
        <version>1.0.2.Final</version>
        <scope>provided</scope>
</dependency>

The provided scope means that this dependency is only used to compile your code and not included in the resulting EAR/WAR/JAR. In the runtime this dependency is provided by your application server (JBoss, Websphere, whatever). If you omit the scope specification section very bad things may happen.

2
votes

Here you go. This is from EJB specs.

<dependency>
    <groupId>javax.ejb</groupId>
    <artifactId>javax.ejb-api</artifactId>
    <version>3.2</version>
</dependency>

Hope this helps.