I have one maven project with the ear structure and I'm deploying the ear on the wildfly 9.0.0
I have one jar with jpa doing the persistence and I have 3 wars that use this jar, if I import this jar on the pom in one of this wars this is ok, but if I import this jar in two wars the CDI doesn't work.
What I really want to do is to expose this one jar to all wars in the ear without importing in every war pom
Stop the server
Open the server configuration file. (standalone/configuration/standalone.xml)
Locate the EE Subsystem Configuration element in the configuration file. The profile element of the configuration file contains several subsystem elements. The EE Subsystem element has the namespace of urn:jboss:domain:ee:1.2.
Replace self-closing tags if necessary
Add ear-subdeployments-isolated element
Start the server
Note that this disables Subdeployment Module Isolation for All Deployments and not only for this deployment. documentation for all deployments
If you want for this specific deployment only you should:
Add the deployment descriptor file
Add the ear-subdeployments-isolated element
This is valid for JBOSS EAP which has pretty similar behavior with JBOSS wildfly.
EDIT: As @Will T has correctly stated in comments in the wars dependencies of the jar with the scope
<scope>provided<scope/> should be added.