FINALLY, I get to help somebody here!
I just did that yesterday.
Here's what you need:
First thing you need to know is that you need a jboss-app.xml file in your ear's META-INF directory, which will look almost exactly like this, first before version substitution and then after:
now after substitution where version was set to "1.2.3":
The above limits your class loader to those classes which exist in the ear specified and the ones loaded into the JBoss server, not to those loaded by another EAR. The current default behavior for JBoss is to share classes from one ear to the next, so if you load version 1.2.2 of the class org.my.software.MyClass first, that's the only one that gets loaded anywhere until you undeploy the 1.2.2 version. First come, first served. The above jboss-app.xml will fix that with probably a slightly bigger footprint.
Now, the next thing you need to do is make a separate name for each version as follows in application.xml and everything else too:
Here's a jboss.xml:
I left out the top couple lines on each file, btw, and just gave the main element.
In your build.xml, you convert @version@ to 1.2.3 (for example) as follows:
Hope this helps.