8

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>
tweetysat
  • 2,187
  • 14
  • 38
  • 75

3 Answers3

7

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.

Martin Höller
  • 2,714
  • 26
  • 44
  • Ok, thanks. So the ejb packaging is not really usefull anymore. – tweetysat Sep 18 '13 at 08:12
  • The resulting JAR will probably be pretty much the same but it's still correct to use the packaging type 'ejb'. And as jay stated, it verifies the existence of the EJB deployment descriptor. – Martin Höller Sep 18 '13 at 08:25
4

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 .

jay
  • 791
  • 8
  • 20
3

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).