When i declare an optional module dependency the outcome (ClassNotFoundException vs. success) depends on the deployment order which is documented in the jboss-deployment-structure-1_1.xsd:
<xsd:attribute name="optional" type="xsd:boolean" use="optional" default="false"> <annotation xmlns="http://www.w3.org/2001/XMLSchema"> <documentation> Specifies whether this dependency is optional (defaults to false). An optional dependency will not cause the module to fail to load if not found; however if the module is added later, it will not be retroactively linked into this module's dependency list. </documentation> </annotation> </xsd:attribute>
But during the server start the deployment order is determined by AS7.1.0.Final and optional dependencies (opposed to mandatory ones) are not taken into account for the deployment ordering which leads to ClassNotFoundExceptions since authentication.war is deployed before myapplication.ear.
Below are the jboss-deployment-structure descriptors i use to expose and reference the dependency:
myapplication.ear (exposes the module):
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1"> <module name="deployment.releasebuild-information" > <resources> <resource-root path="lib/release-info.jar"> </resource-root> </resources> </module> </jboss-deployment-structure>
authentication.war (references the exposed module)
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1"> <deployment> <dependencies> <module name="deployment.releasebuild-information" export="true" optional="true"/> </dependencies> </deployment> </jboss-deployment-structure>
As soon as i set optional="false" the deployment order during server start changes and deployment.releasebuild-info ist reachable from within authentication.war. Is the different deployment order depending on the optional flag a bug or am i wrong in expecting to to see the same order for a mandatory and for an existing optional dependency?