Alisson Alvarenga Alisson Alvarenga - 1 year ago 123
Java Question

Expose one jar to many wars in ear structure

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

Answer Source

You can:

  1. Stop the server

  2. Open the server configuration file. (standalone/configuration/standalone.xml)

  3. 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.

  4. Replace self-closing tags if necessary

  5. Add ear-subdeployments-isolated element

  6. 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:

  1. Add the deployment descriptor file

  2. Add the ear-subdeployments-isolated element

    documentation for specific deployment

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download