Dennys
Dennys

Reputation: 609

Specifying an ejb client as dependency in Maven

I have 2 EJBs A and B (in different jar files), EJB A calls one method of EJB B.

From the following Maven's documents, I use generateClient to create a ejb-client and use ejb-client dependency to get the jar. http://maven.apache.org/plugins/maven-ejb-plugin/examples/generating-ejb-client.html http://people.apache.org/~aramirez/maven-ejb-plugin/examples/ejb-client-dependency.html

It's ok to use Maven to build, deploy and run. The problem is, although project A only needs the interface class of EJB B, but Maven includes all EJB B's dependency libraries into EJB A's dependency. The result is EJB A will have lots of non-necessary jar files. Is there any solution to fix it?

Upvotes: 4

Views: 3703

Answers (2)

Dennys
Dennys

Reputation: 609

I found another solution, Maven's dependency has exclude function and I use it to remove some jar files.

<dependencies>
   <dependency>
       <groupId>com.example</groupId>
       <artifactId>ejb-project</artifactId>
       <version>1.0-SNAPSHOT</version>
       <type>ejb-client</type>      
       <exclusions>
         <exclusion>
           <groupId>sample.ProjectD</groupId>
           <artifactId>Project-D</artifactId>
         </exclusion>
       </exclusions>          
   </dependency>       
</dependencies>

Upvotes: 2

amra
amra

Reputation: 16885

The only way is to move interface of EJB B to a separate jar. Then use it as dependency in EJBs A and B project/modules.

Upvotes: 0

Related Questions