Search code examples
jboss7.xejb-3.0warear

Multiple Wars sharing common EJB JAR


I have a jar that contains many EJBs and I need to access those from multiple WARs. I'm trying to figure out the best way to package and deploy these to a single app server.

Currently, I deploy each WAR individually with each having a dependency on the common EJB jar, but this seems to be incredibly inefficient (memory-wise et al) as there are separate JNDI bindings for each application.

I've also tried packaging these WARs in an EAR but this doesn't seem to change anything.

Does this make any sense? How can I make sure that the common EJB jar is not "deployed" multiple times (once for each WAR that depends on it)?


Solution

  • To solve your issue you need to have one ear with 3 modules - 2 wars and 1 ejb. Do not include EJB in the WARs as you will have duplicates. Dependency should result only in classpath setting, not including jar in war files.

    Classpath entry might be created via war plugin configuration

     <manifestEntries><Class-Path>project-ejb-${project.version}.jar</Class-Path>
    

    or ear plugin configuration:

    <skinnyWars>true</skinnyWars>
    

    See skinnyWars description for more details.