Pretty easy, you only have to edit the deployment descriptors for your beans and services. Use different JNDI names for your datasources and for the ejbs in your ears.
I recommend using an own loader repository for every ear (jboss-app.xml)... read the jboss-app_3_0.dtd in your docs/dtd directory how to do this. You can deploy the datasources each with your ear or both standalone.
I even recommend reading the J2EE spec (Chap. 8) for packaging and the documentation about Class Loading Architecture of JBoss on sourceforge ( http://sourceforge.net/project/showfiles.php?group_id=22866&release_id=163973 ).
I am currently using JBoss 3.2.1 and I am trying to deploy two ear files (test1.ear, test2.ear) each containing the same ejbs. They need to connect to different datasources though.
For each ear file, I use different JNDI names for the datasources and for the ejbs.
However, when I deploy test1.ear and test2.ear respectively into JBoss, the ejbs in test2.ear always connect to the datasource specified in test1.ear.
This problem didn't happen if I deploy only one of the ear file. I have modified jbosscmp-jdbc.xml and the -ds.xml in the two ear files. Are there any additional configuration parameters that I need to modify?
What do the two jbosscmp-jdbc.xml files in the two ear files look like?