How to control class loading order between 2 ears
conorroche Dec 20, 2012 7:49 AMHi,
I am using jboss 7.1.3 in standalone mode where I have ear files in the deployments folder.
I have 2 separate ears where one ear's ejb jar depends on the classes of another ear's ejb jar, and i can not get them to start consistently in the correct order.
This results in intermittent class not found errors on startup when the 2nd ears ejb module loads before the other which prevents the ears from starting.
If for example the ear structure is this:
master.ear
master-ejb.jar
slave.ear
slave-ejb.jar
where slave-ejb.jar depends on master-ejb.jar
I have tried controlling the order as follows:
a) adding a Dependencies reference to the MANIFEST.MF of the slave-ejb jar: Dependencies:deployment.master.ear.master-ejb.jar
b) adding a top level deployment module dependency on the ear to slave.ear's jboss-deployment-structure.xml:
<deployment>
<dependencies>
<module name="deployment.master.ear.master-ejb.jar"/>
</dependencies>
</deployment>
c) adding a sub deployment module dependency on the ear to the slave.ears jboss-deployment-structure.xml:
<sub-deployment name="slave-ejb.jar">
<dependencies>
<module name="deployment.master.ear.master-ejb.jar"/>
</dependencies>
</sub-deployment>
d) renaming the ear files to ensure master comes first
e) making the module dependency optional
While the above will make the master classes available to the slave module (when they intermittently startup in the right order) none of the above allow me to make the class loading sequential, presumably because of the concurrent module class loader.
I can not copy the required master classes into the slave ear as they are used for local jndi and would be different classes in different class loaders so jndi will not work.
I suspect there are 2 workarounds that i have (neither of which is ideal as will require a large amount of project restructuring for us as we actually have a lot more than 2 ears):
1) Split the shared ejb client interfaces and pojos into a separate module and put in the modules dir and have both ears depend on it
2) Merge the 2 ejbs into a single ear
In JBoss 4.2.3GA the same apps worked because ears would a) load based on the file name eg. we could use this to control ear load order and b) because the ears ejb jars were loaded into the UCL
Does anyone know of a way to allow make the modules class loader support some form of sequential module class loading?