3.2. Add an Explicit Module Dependency to a Deployment
Prerequisites
- You must already have a working software project that you want to add a module dependency to.
- You must know the name of the module being added as a dependency. See Section 3.8.2, “Included Modules” for the list of static modules included with JBoss EAP 6. If the module is another deployment then see Section 3.1.7, “Dynamic Module Naming” to determine the module name.
- Adding entries to the
MANIFEST.MF
file of the deployment. - Adding entries to the
jboss-deployment-structure.xml
deployment descriptor.
Procedure 3.1. Add dependency configuration to MANIFEST.MF
MANIFEST.MF
file. See Section 3.3, “Generate MANIFEST.MF entries using Maven”.
Add
MANIFEST.MF
fileIf the project has noMANIFEST.MF
file, create a file calledMANIFEST.MF
. For a web application (WAR) add this file to theMETA-INF
directory. For an EJB archive (JAR) add it to theMETA-INF
directory.Add dependencies entry
Add a dependencies entry to theMANIFEST.MF
file with a comma-separated list of dependency module names.Dependencies: org.javassist, org.apache.velocity
Optional: Make a dependency optional
A dependency can be made optional by appendingoptional
to the module name in the dependency entry.Dependencies: org.javassist optional, org.apache.velocity
Optional: Export a dependency
A dependency can be exported by appendingexport
to the module name in the dependency entry.Dependencies: org.javassist, org.apache.velocity export
Procedure 3.2. Add dependency configuration to jboss-deployment-structure.xml
Add
jboss-deployment-structure.xml
If the application has nojboss-deployment-structure.xml
file then create a new file calledjboss-deployment-structure.xml
and add it to the project. This file is an XML file with the root element of<jboss-deployment-structure>
.<jboss-deployment-structure> </jboss-deployment-structure>
For a web application (WAR) add this file to theWEB-INF
directory. For an EJB archive (JAR) add it to theMETA-INF
directory.Add dependencies section
Create a<deployment>
element within the document root and a<dependencies>
element within that.Add module elements
Within the dependencies node, add a module element for each module dependency. Set thename
attribute to the name of the module.<module name="org.javassist" />
Optional: Make a dependency optional
A dependency can be made optional by adding theoptional
attribute to the module entry with the value oftrue
. The default value for this attribute isfalse
.<module name="org.javassist" optional="true" />
Optional: Export a dependency
A dependency can be exported by adding theexport
attribute to the module entry with the value oftrue
. The default value for this attribute isfalse
.<module name="org.javassist" export="true" />
Example 3.3. jboss-deployment-structure.xml with two dependencies
<jboss-deployment-structure> <deployment> <dependencies> <module name="org.javassist" /> <module name="org.apache.velocity" export="true" /> </dependencies> </deployment> </jboss-deployment-structure>