Unless you provide some more specific information, any attempt to give you an answer will be largely guesswork.
What version are you using?
How have you configured the datasource?
How have you configured the login module?
Is the name you're using the mapped name from your EJBs?
What is the exception stacktrace from the server?
The code you've given is client side code - but the relevant exception information will be in the server log.
thanks for the reply, but I think I cracked it over the weekend. The problems was that the client side code was finding the server-side auth.conf (it's all on one machine) and was therefore trying to use the database connection from outside the JBoss container.