By default, Jboss just bind the datasourc in local jndi namespace, so you cannot retrieve it out of jboss jvm. If you want that, you should bind the datasource to the global namespace :
In XX-ds.xml, under <jndi-name>, add this:
<use-java-context>false</use-java-context>
btw, you must use jboss4.0