Look in jndi-view from the jmx console to find out what your datasource is bound under globally and use that. It will look like
java:/myds without the comp/env part that you are currently using. There isn't a way to set up local references for mbeans so you will have to use the global jndi name.
After some experimentation, it appears that the hibernate.sar is loading before the datasource is bound. Is there a way to control the load order of the jmx modules (a dependancy setting perhaps)?
Btw, only the global name worked.
Thanks for your help!
If the Hibernate stuff is controlled by a mbean that follows the jboss service lifecycle, (has a start method, in which the jndi lookup occurs), then you can include a jboss.jca:service=TxCM,name=[the jndi name] element in the jboss-service.xml file in the .sar. Check the jmx console for the exact object name.
If it just starts when created, the easiest thing to do is probably include the *-ds.xml in the .sar (at the root) With at least the most recent 3.0 and 3.2 it should get deployed, and first.
You can also name your packages 1mydb-ds.xml, 2hibernate.sar etc and use the prefix deployment sorter.
Solved it with a depends element. Thanks for the help.