java – Specifying an EJB-client with Maven

Question:

I'm not able to use the interfaces of an EJB-client generated by Maven.

I basically have 2 separate projects with different functions. An EAR that contains EJB's and a WAR that uses interfaces from the EJB's from the EAR package.

Here's structure:

  1. EAR

    1.2 – EJB

  2. WAR (with EJB-client dependency).

When I compile the WAR it comes with all the classes from the EJB module and not just the interfaces necessary for its use.

Here is pom.xml from the WAR project:

<dependency>
  <groupId>br.com</groupId>
  <artifactId>dependencia-ejb</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <type>ejb-client</type>
</dependency>

Answer:

For those who are facing the same problem, here is the solution:

If all your projects (both the EAR that contains the EJB's and the WAR that uses the EJB's client interfaces) are in the same workspace, you must close the EJB project before generating the WAR with the EJB-CLIENT interfaces, otherwise , the WAR project will be compiled with all the EJB classes and not just the required client interfaces.

Scroll to Top