Skip to content
Advertisement

Shared Dependency for two Deployments on Wildfly

I have two webapps, which are deployed within the same wildfly. Both webapps should share certain libraries, which are not part of the wildfly modules.

To keep the deployment non-dependent on the specific wildfly, I would prefer not to provide the shared libraries via the wildfly-module system (I am aware, it is possible to user-define modules).

My approach was to simply put the library in the deployment directory along with both webapps and reference them within the respective jboss-deployment-structures. This, however, has failed.

I tried to embed the library within a war and reference it via

<module name="test.war" />

it would not work, as the module is not found. I have found a document from redhat which lead me to thinking this might work: Redhat

I also testet putting the bare jar within the deployment dir and referencing it via resource-root:

<resources>
  <resource-root path="my-library.jar" />
</resources>

This bootet but the classes from the library are not visible to the deployment.

So my question is: Is there a way to deploy a library within the deployments dir on wildfly an use it from an EAR/WAR Deployment?

Answer

This was a simple mistake, re-reading the manual solves it.

If you reference a deployment from the deployments directory, you have to specify you do so. So, accessing b.war from a.war, you have to provide a jboss-deployment-structure which reads

<dependencies>
    <module name="deployment.b.war" />
</dependencies>

If you do so, webapp A can access all java classes defined in webapp B.

Advertisement