3 Replies Latest reply on Sep 18, 2018 8:43 AM by jewellgm

    EAR shared libraries

    a.gvozdik86

      I have the application with many dependencies. I want to move 3rd party dependencies (some of them not 3rd party, but I don't need to update it very often).

      I was trying to use JBoss module with all my dependencies, but I was not able to deploy my application.

      I've created separate EAR project with all my dependencies. I'm using maven-shade-plugin to merge resources  with the same name (META-INF/spring.handlers, META-INF/spring.schemas).

      In my main EAR project I have sub-deployment dependency to my new EAR with 3rd party.

      I'm deploying EAR-dependencies and then EAR with my main application. EAR-dependencies deploys successfully, but not main application.

      The problem is after main application loads some of classes from EAR-dependencies (Spring is trying create beans. Spring is located in ear-dependencies) I have ClassNotFoundException.

      This class is loading with EAR-dependencies module class loader and this class has injected implementation from EAR main file.

       

      Why my main application can get classes from EAR-dependencies, but not vice versa?

      <?xml version="1.0" encoding="ISO-8859-1"?>  
      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">  
      <ear-subdeployments-isolated>false</ear-subdeployments-isolated>  
      <sub-deployment name="mainapplication.war">  
      <dependencies>  
      <module name="deployment.eardependencies.ear" meta-inf="import" />  
      </dependencies>  
      <local-last value="false" />  
      </sub-deployment>  
      </jboss-deployment-structure> 
      


        • 1. Re: EAR shared libraries
          jewellgm

          You've got a circular dependency, which raises all kinds of red flags.  The first thing I would suggest doing is to figure out a way to package your ears so that they aren't dependent on each other.  Having said that, the "ear-subdeployments-isolated" tag only works within a single ear - it doesn't make classes globally visible across all deployments.  You would need to also add a jboss-deployment-structure.xml to your dependencies ear and make it dependent on your main application.  You should really try to resolve the circular dependency though.

          • 2. Re: EAR shared libraries
            a.gvozdik86

            jewellgm  написал(-а):

             

            You would need to also add a jboss-deployment-structure.xml to your dependencies ear and make it dependent on your main application.

            I can not do this because I'm getting "module not found" error in case when I try to deploy dependencies.

            Is it possible to do bidirectional library sharing?

            • 3. Re: EAR shared libraries
              jewellgm

              The only way that I can think of how to accomplish what you want is to remove the jar from the application ear, and then put that into a wildfly module.  You would then need to make both ears dependent on that module.

               

              I am guessing that your code repository still has things set up with circular dependencies at compile-time though.  Ideally, the best thing to do is to refactor the code to resolve it.

              2 of 2 people found this helpful