tags:

views:

113

answers:

1

Let's say I have two ear file and one .jar file with an EJB that both of the EARs use. I want to do this because in some cases I might deploy one ear to an app server, but in others I might want to deploy both and I don't want to create different ear file for each scenario.

How do I best package the "client" classes for the EJB? Using JBoss I can put them pretty much anywhere and it seems to work since it has a shared classloader. But I wonder what the official way to do this is?

+1  A: 

Put the common ejb jar file in both ears. EAR's are supposed to be standalone pacakages, with external setup via JNDI

When it comes to EAR's, you don't buy yourself anything but classloader problems when you try to "save space", or "DRY" with jar files between them.

Jim Barrows
If I deploy both ears to the same app server, then one of them would fail, right? Because it would try and load the same EJB twice? But it seems like maybe I cannot really do what I want in a "portable and approved" way.
Dave
@Dave: They will not clash, they'll be loaded with different classloaders and put on different parts of the JNDI tree. Trust the app server, it's your friend :)
skaffman