jboss as 6: perplexed by classloading
jjfraney Jun 8, 2011 9:54 AMIn short: what is best deployment model for my project? and what information is needed in configuration files to make this best deployment model work?
I have two applications that are dependent on the same model. One app is a seam gui. One app is an EJB that is a client to a web service. The model is implemented as JPA entities and there are a few common business rules implemented as session beans.
My first approach is to put the JPA entities and business rules in an ejb archive (model.ejb) and bundle that in each of the two apps. (gui.ear, and webclient.ear). The downside is
- we cannot easily see what release of the model.ejb our apps are using.
- there would be two binaries of model.ejb in deploy directory, one deployed with each app, and versions have to be the same, requiring a repackaging of an app even if it is not affected by a new version of the model.
- the persistence.xml file is in the entities jar, and jboss tries to load both; one fails because they both have the same persistence unit name.
So, second approach was to build an ear with entities and the few common session beans. I could not get this exactly right in terms of configuration. In this ear, I provided the jboss-classloading.xml file, with these contents:
<classloading xmlns="urn:jboss:classloading:1.0"
parent-domain="DefaultDomain"
export-all="NON_EMPTY"
import-all="true">
</classloading>
The intent is to export the jpa classes to the apps through a common classloader. This seemed to work but only on the first jboss installed system that I was using to develop. When I moved it to an integration system, it stopped working, or I fat fingered a configuration along the way. A named query defined on the jpa entity in the model ear is not found in a call to createNamedQuery by at least one of the other apps (the web client app). Why would this named query resolve in one system and not another (what did I screw up in the transition)? <scratch, scratch>
So, now, down to a third approach, and just for grins: I deploy the model and the common session beans as separate normal jar files. jboss-classloading.xml file is absent in both. This seems to work, and I don't know why.
So, I prefer the second deployment, but I don't know why it doesn't work. I'd use the third if I have to, but I don't know why it does work. Is there a jee specification or jboss document that would clarify? or are the answers earned only be trial of fire? In any case, any advice from an expert?
Thanks.