Fabrizio Stellato
Fabrizio Stellato

Reputation: 1901

maven install how to install and deploy *ONLY* ejb-client

I'm using the maven-ejb-plugin to generate ejb client for my client, in the standard way

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ejb-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <ejbVersion>3.0</ejbVersion>
        <generateClient>true</generateClient>
    </configuration>
</plugin>

So the client use its dependecy

<dependency>
    <groupId>en.foo.ejb</groupId>
    <artifactId>artifact-ejb</artifactId>
    <version>1.0.0</version>
    <type>ejb-client</type>         
</dependency>

I'm having 2 issues so far:

  1. Launching mvn clean install or mvn clean deploy install ALSO the whole ejb package jar, so in the end I'll have both
    • artifact-ejb.jar
    • artifact-ejb-client.jar

I'd expect to install only the second one, because the artifact-ejb.jar should not be installed on the repository

  1. The ejb artifact includes a parent pom, so when the client try to resolve all the dependencies it says the parent pom cannot be found on the repository, however the parent it is not meant to be distributed because it is only a reference.

(see also https://howtodoinjava.com/maven/maven-parent-child-pom-example/)

How can I solve these issues ?

Upvotes: 0

Views: 762

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35843

Your artifact-ejb-client.jar contains only the interfaces. At runtime, you need to have the implementations as well. So if you want to build a proper ear or war, you need both artifact-ejb-client.jar and artifact-ejb.jar. The only exception that comes to my mind is RMI communication where you would be fine having only the client (on the calling side). So think about whether you really want to keep the artifact-ejb.jar out of your repository.

If you decide to do so, split your project into two separate projects, one containing the interfaces and one containing the implementations. The impl-project needs the client-project as dependency. Then you can freely build and deploy just one of the two.

For the parent poms: All parent poms of your artifacts need to be in the repository, otherwise the builds will break. If you depend on an artifact, you need to resolve its parent pom. It cannot be kept "secret".

Upvotes: 1

Related Questions