I have an issue here with deployment order in general and the timing in particular.
I have an ear 1 which provides some functionality via a bean and some queues. The queues are configured in the standalone.xml. Another ear 2 which uses this service from ear1.
So the dependency looks like: ear1 <-- ear2
So I configured the deployment structure of ear 2 to depend on ear 1 and the deployment order itself is correct now.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="deployment.ear1.ear" />
</dependencies>
</deployment>
</jboss-deployment-structure>
The deployment order is correct now, but what I now have is a race condition due to a (I guess) not initialized bean from ear 1.
When I delay the deployment of ear2, everything works fine.
Does anyone know how to control the timing of the deployment. Can one specify not only the order of the deployments via jboss-deployment-structure.xml, but also the lifecycle which needs to be reach to start the next deployments?
UPDATE
I tried to specify the actual bean jar which contains the service to be used. This is not working, too. It looks like:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="deployment.ear1.ear.bean.jar" />
</dependencies>
</deployment>
</jboss-deployment-structure>
As you probably know by now, the inter-ear depenendencies will be introduced in JBoss 7.2.
I had the same issue with one EAR defining services used by other EARs. I have solved this by completely turning off auto-deploy in standalone.xml:
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
<deployment-scanner path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-zipped="false" auto-deploy-exploded="false"/>
</subsystem>
And running the following script in separate thread just before starting JBoss. The script creates a list of deployments and deploys them in specified order using JBoss 7 deployment scanner marker files. I.e. It creates .dodeploy marker for 1st deployment, then waits until it gets deployed, then creates .dodeploy marker for 2nd deployment etc.
#!/bin/bash
function contains() {
local n=$#
local value=${!n}
for ((i=1;i < $#;i++)) {
if [ "${!i}" == "${value}" ]; then
echo "y"
return 0
fi
}
echo "n"
return 1
}
DD="/home/martinv/jboss-as-7.1.1.Final/standalone/deployments"
ORDER_FILE="/home/martinv/order.txt"
echo "[MDC] Manual deployment control"
echo "[MDC] -------------------------"
echo "[MDC] Removing markers"
rm -f $DD/*.dodeploy $DD/*.isdeploying $DD/*.deployed $DD/*.failed $DD/*.undeployed $DD/*.pending $DD/*.isundeploying
APPS_ALL=( $( ls -1 $DD | grep '.ear$\|.jar$\|.war$\|.sar$' ) )
APPS_ORDER=( $( cat $ORDER_FILE ) )
echo "[MDC] ${#APPS_ALL[@]} apps in $DD: ${APPS_ALL[@]}"
echo "[MDC] Order defined for ${#APPS_ORDER[@]} apps: ${APPS_ORDER[@]}"
for APP in "${APPS_ALL[@]}"
do
if [ $(contains "${APPS_ORDER[@]}" $APP) == "n" ]; then
APPS_ORDER=("${APPS_ORDER[@]}" "$APP")
fi
done
echo "[MDC] Final order of ${#APPS_ORDER[@]} apps: ${APPS_ORDER[@]}"
for APP in "${APPS_ORDER[@]}"
do
echo "[MDC] Scheduled for deploy: $APP"
touch "$DD/$APP.dodeploy"
while [ ! -f "$DD/$APP.deployed" -a ! -f "$DD/$APP.failed" ]; do
sleep 1
done
RESULT=`ls -1 $DD | egrep "$APP.failed|$APP.deployed"`
echo "[MDC] Finished deploying $APP, result: $RESULT"
done
The way I have done this in the past is by modifying the name of the ear files. The deployments seem to be performed in alphabetic order. If you want ear1 to be deployed first, rename it to say a_ear1.ear and ear2 to say z_ear2.ear.