As you use EJB 3, you must be using JBoss 4 or above.
It happens that on JBoss 4 (of another anterior version), the classloading of JBoss have changed. Now, it seems that it load the resources in alphabetic order.
Try to change the name of u Datasource deployment to something like 1_my-ds.xml and try again (put a number before).
It must load u datasource first, them u SAR.
Have now tried your suggestion, but unfortunatelty it hasn't made the slightest bit of difference. I've tried it with a '1' at the start of the name and the letter 'a', but no joy. Would seem to be a strange behaviour of JBoss if that were the case. Surely dependencies should be satisfied ahead of any other deployments.
You say that the sar makes use of the EJB3 entity bean, this in turn makes use of the datasource.
Instead of making your SAR depend on the datasource that will be deployed early have you tried making it depend on the entity bean deployment instead?