Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven 2 & Packaging ejb vs jar

If i'm working with ejb 3.1, what's the différence between

<packaging>jar</packaging>

and

<packaging>ejb</packaging>
...
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ejb-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <ejbVersion>3.1</ejbVersion>
    </configuration>
</plugin>
like image 304
tweetysat Avatar asked Sep 18 '13 07:09

tweetysat


3 Answers

Using packaging type ejb includes the execution of the maven-ejb-plugin. This is not the case for packaging type jar (unless you explicitly configure it). The plugin configuration as stated in the original question is only required if you need to define a configuration that differs from defaults.

To my knowledge the main purpose of the maven-ejb-plugin is (was) for creating an EJB client module (only including interfaces). But IMHO this is no longer the recommended way. Usually you provide the APIs via a separate module and do not let the ejb-plugin create it automatically.

like image 84
Martin Höller Avatar answered Sep 29 '22 20:09

Martin Höller


As mentioned at http://maven.apache.org/plugins/maven-ejb-plugin/usage.html ,

"The plugin doesn't do any EJB specific processing during the generation of the jar except for validating the existence of an EJB deployment descriptor if the EJB version is 2.0+ "

Since you have ejb 3.1 the ejb-jar.xml file is optional hence unless you want to generate client stubs and utility classes as mentioned in Martin' comments , it won't make much a difference if you use jar packaging .

like image 39
jay Avatar answered Sep 29 '22 20:09

jay


I would also suggest comparing effective pom outputs from maven help plugin for both jar and ejb project types:

mvn help:effective-pom

It will allow to compare what maven generates for ejb projects and for jar projects.

The difference between ejb and jar also makes sence when packaging into ear plugin. As a rule, ejbModule configuration property is used for ejb-jars, containing beans, while jarModule configuration property of the ear plugin is used for libraries (jar archives).

like image 32
Sergei Zhylinski Avatar answered Sep 29 '22 21:09

Sergei Zhylinski