If I understand what you are saying,
Try using the Environment Naming Context (ENC) and
This way you can deploy the very same EJBs using
different names that can be set at deploy time.
Example: Xejb referrs to Yejb. Inside Xejb I would
use "java:comp/env/ejb/Yejb" when I look it up and
have an EJB reference to it in the ejb-jar.xml
Think of using "java:comp/env/ejb/?" as an alias.
Then at deploy time in jboss.xml I could give Xejb
any JNDI name and map its use of "java:comp/env/ejb/Yejb"
to anything I like.
The same holds true for resource names like databases.
I can refer to "java:comp/env/jdbc/DataBase" in my code
and map its resource reference to anything I like at
All this without having to change any code.
In general, directly coding JNDI references from the
gobal namespace in your EJBs, Servlets, etc is not a
very good idea.
Hope this helps.