did you include a jboss-web.xml file in your web application's WEB-INF folder? You can specifiy jndi mappings within that file like this:
That way you will not have to edit source code no matter where the resource is really located on you jndi server. Which also makes moving your app from one environment to another simple.
I have similiar problem. I will not use any proprietary XML conf file. My EAR HAVE to be app server independent. But as long as I have seen, every App server is trying to sabotage plataform independence...
It´s IMPOSSIBLE to build an EAR that works in JBOss and Sun´s J2EE. That´s my opinion. And it happens becouse of this comp/env incompatibility. If you get any closed EAR that access DB from Sun it will not work unchanged on Jboss.
I´d like to see an EAR that works unchanged and only with sun´s default XML configuration, with Entity beans,session beans, servlets, jsp and DB access that work on JBoss and J2ee. As I doubt that it will work unchanged in other Web App Servers ...