I have an ejb1.jar module that by simplicity has a EJBHomeFactory session bean that caches references to other bean homes. The module by itself works fine.
But I need to include two such modules (driving and driven) in the same application (I have two similar database schema with references to each other). And the driving EJBHomeFactory has reference to the driven EJBHomeFactory. To avoid class duplication, I moved all classes to ejb-classes.jar. Ejb1.jar and ejb2.jar actually contain only descriptive xml files and reference to the ejb-classes.jar. Of course, all beans have unique JNDI names. The application is installed successfully. The driving EJBHomeFactory returns correct references to its module beans. But when I received references to the driven EJBHomeFactory and ask it to return some its entity beans pointed to the second database, it actually returns beans filled with data from the first database (of course if you have records in the tables that share the same primary key). So more interesting it happens only with references to Entity beans. With Session beans I have no problem (it seems). So it is look like a sophisticate bug either in bean reference or in Entity bean JNDI cache that cache entity beans instances not by JDNI name / primary key, but java.lang.Class instance / primary key.
So more interesting, if I separate the modules into two applications this bug disappears, but in that case I have problem with class casting.
My application works fine on WebLogic. I understand that my situation is not common. But may be JBoss developers can fix it in the future. It was tested up to JBoss 3.2.3.