Although the EJB3.1 specification represents a singleton, and your version of JBoss does not support it, you can use the JBoss @Service annotation to create a singleton. Instructions are here . Also, it looks like your JBoss is set to isolate banks and ejb wars from each other. You do not have to do this. You can look at the loader-repository tag in specific jboss xml files so that your whole ear is shared by one classloader (or, perhaps, at least two wars share the same classloader).
All that has been said, I agree with @duffymo that a singleton sharing a fortune between two wars is the idea that you should go if you don't run away.
Edit: Regarding singletones, I suggest you look at issues like this one (which also has a nice balance in the comments).
The idea of ​​having an object’s caching state is okay on its own, especially with EJB3, where you can enter your state rather than statically refer to it (if you use the @Service annotation, then you want the @Depends JBoss annotation). At the same time, if you used the "correct" singleton here, I would expect that your only problem with the fact that your WARs have two separate class loaders is the extra memory. Otherwise, you get into the problem area of ​​singletones (where they must be initialized for use, everything that uses them should ensure that they are initialized first, and, of course, all the code is strongly related to their initialization).
If singletones are really very bad, they store state, so one class can change state, and another class selects it. This is basically a no-no in EJB prior to 3.1, and even then it makes a lot of concurrency problems.
Edit (further): So you want to go with the classloader repository. I use JBoss 4.2.3, so I don’t necessarily know all the inputs and outputs of JBoss5 (which rewrote its class loader, although they say that it is almost completely backward compatible), however in 4.2.x your configuration doesn’t cause it by default because that all ears deployed on the server have the same classloader ("unified classloader"). I suspect that the server on which you are deploying has a different configuration, so I'm not sure that it can be contacted, but you need to add a file called jboss-app.xml in your ear (in the same place as and application.xml), which looks something like this:
<?xml version="1.0"?> <!DOCTYPE jboss-app PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN" "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd"> <jboss-app> <loader-repository> com.yourcomany:archive=yourear </loader-repository> </jboss-app>
This is for JBoss 4.2. 5.1 has a tag of the same type, here is xsd . It has the same storage loader concept.
It should be like that. That is, as long as your ejb-jar, war, etc. They do not have it, then they do not need it. However, your wars (in jboss-web.xml - the same place as web.xml) may need the same. In this case, while you name the repository in exactly the same way (if I understand correctly, I never tried it myself), they will use the same classloader. The same goes for EJB, which is configured in jboss.xml, which is in the same place as ejb.xml.
This can make it a little clearer.