Dependency attribute optional="true" not supported for deployment modules?
r.reimann Jan 11, 2012 10:48 AMSetting optional="true" on a dependency in jboss-deployment-structure.xml didn't work as expected. Allthough the dependency is declared as optional the dependent WAR fails when the optional dependency isn't present:
14:59:03,837 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) Starting deployment of "dependency-consumer.war" 14:59:04,234 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS015856: Undeploy of deployment "dependency-consumer.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.module.service.\"deployment.dependency-consumer.war\".mainjboss.module.spec.service.\"deployment.optional-dependency\" .mainMissing[jboss.module.service.\"deployment.dependency-consumer.war\".mainjboss.module.spec.service.\"deployment.optional-dependency\".main]","jboss.deployment.unit.\"dependency-consumer.war\" .POST_MODULEjboss.module.spec.service.\"deployment.optional-dependency\".mainMissing[jboss.deployment.unit.\"dependency-consumer.war\".POST_MODULEjboss.module.spec.service.\"deployment.optional-dependency\".main]"]} 14:59:04,250 INFO [org.jboss.as.server.deployment] (MSC service thread 1-14) Stopped deployment dependency-consumer.war in 26ms 14:59:04,251 INFO [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report JBAS014775: New missing/unsatisfied dependencies: service jboss.module.spec.service."deployment.optional-dependency".main (missing) dependents: [service jboss.deployment.unit."dependency-consumer.war".POST_MODULE, service jboss.module.service."deployment.dependency-consumer.war".main] 14:59:04,252 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.module.service.\"deployment.dependency-consumer.war\".mainjboss.module.spec.service.\"deployment.optional-dependency\" .mainMissing[jboss.module.service.\"deployment.dependency-consumer.war\".mainjboss.module.spec.service.\"deployment.optional-dependency\".main]","jboss.deployment.unit.\"dependency-consumer.war\" .POST_MODULEjboss.module.spec.service.\"deployment.optional-dependency\".mainMissing[jboss.deployment.unit.\"dependency-consumer.war\".POST_MODULEjboss.module.spec.service.\"deployment.optional-dependency\".main]"]}}}
jboss-deployment-structure.xml of dependency-consumer.war:
<jboss-deployment-structure> <deployment> <dependencies> <module name="deployment.optional-dependency" optional="true" /> </dependencies> </deployment> </jboss-deployment-structure>
jboss-deployment-structure.xml of dependency-provider.ear:
<jboss-deployment-structure> <module name="deployment.optional-dependency"> <resources> <resource-root path="my-optional.jar" /> </resources> </module> </jboss-deployment-structure>
When i change the module name referenced by the consumer to something without the deployment. prefix (e.g. "dependency-producer-ear.my-dependency" the optional flag seems to work. I can deploy the dependency-consumer.war without having the dependency-provider.ear deployed. But unfortunately i can't declare such a name within the consumer since it leads to the exception shown below.
javax.xml.stream.XMLStreamException: Additional module name dependency-producer-ear.my-dependency is not valid. Names must start with 'deployment.'
Is it a bug that the optional flag is ignored for deployment modules? I couldn't find any hint (neither in the classloading documentation nor in the jboss-deployment-structure-1_1.xsd) that optional isn't supported for deployment modules.