The problem is that this is not the same as the EJB reference to the ear module that will be used to deploy it on the server, than to the link from the client that needs EJB classes to communicate with the server.
If you enable dependency in an ear module, it will consider that you are declaring an EJB module for deployment. It will put it in the root of the EAR and declare it in application.xml.
If you include a dependency, for example, in a military module, you will get exactly the same artifact, but it will be considered as a library and placed in WEB-INF / lib.
Now that you are generating skinny wars, explicit dependency on the ejb module makes the dependency mismatch in WAR, since Maven does not consider them the same. This causes the JAR to be stored in the WAR / s that use it.
The only thing I know is to always generate a client artifact for the ejb module, even if the client artifact is identical to the main artifact.
Now you only use the <type>ejb</type> dependency in the EAR. For clients, you always use <type>ejb-client</type> .
To remove a client from WAR / s and find it in the lib EAR directory, you must explicitly add the dependency to the ear module.
So, you will have two dependencies to the ejb module in your ear module: one to ejb itself and one to the client. The first will put the EJB in the root of the EAR and declare it in application.xml. The second will put the client in the lib EAR directory and update WAR / s manifest / s if necessary.
But if the client and the main artifacts are identical, can you duplicate it?
The short answer is yes. The long answer is yes. It is duplicated, but only once, and not in every WAR that uses it. I do not think that there is a pure way to avoid this, and I am not sure if this makes sense conceptually. Of course, you can use packageExcludes and customize manifests, but it makes sense to have a JAR twice.
If your JAR client is really thinner (for example, only interfaces) that have a WAR / s link, the client JAR effectively denies them access to EJB implementations, which is always a good idea.
You can consider an identical JAR as a special case of the previous one, and it makes a conceptual meaning to keep them separate.
So, my recommendation is to always generate a client artifact for ejb and act as explained. There are always things that you can exclude from it, at least any unnecessary files without a class, such as package.html or ejb-jar.xml.