Tuesday, October 29, 2013

  • Multiple WARs in single EAR

    Hi
    We have to create an EAR file that should have two WAR files. But these two WAR files share common application libraries. The two WAR files are build and added to EAR. When this EAR is deployed, the common classes are loaded twice resulting in duplicate spring beans, spring schedulers.

    How can these common libraries be loaded only once? should they be removed from one WAR file? What should be the EAR structure.

    Thanks in adv
  • Hi

    Do these WARs contain their own libs or do they use common (e.g. ear/lib/*.jar) JARs and META-INF/MANIFEST.MF with Class-Path: entry?

    regards
    Grzegorz Grzybek
  • Jus like Grzegorz Grzybek mentioned you should reconfigure your project to have both your pointing to the libraries in the EAR. That means all the libraries in the that will be needed by your 2 war file should be in the EAR lib folder and none of the jars should be in the WEB-INF/lib folder of any of the ear files.
  • Here's Maven WAR Plugin configuration:
    Code:
    
      ear
      
        
          
            maven-war-plugin
            
              
                jar
              
              WEB-INF/lib/*.jar
              
                
                  true
                  lib/
                
              
            
          
        
      
    
    And Maven EAR Plugin configuration:
    Code:
    ear
    
    
      
        
          maven-ear-plugin
          2.6
          
            src/main/application/META-INF/application.xml
            false
            UTF-8
            lib/
            true
            
              
                g1
                a1
                web1.war
              
              
                g2
                a2
                web2.war
              
              ...
            
          
        
      
    
    
    
    
      
        g1
        a1
        war
      
      
        g2
        a2
        war
      
      ...
    
    
    happy mavening 

No comments: