2 Replies Latest reply on May 22, 2017 7:13 PM by kmark

    Module of Modules?

    kmark

      Hello,

       

      Apologies if this is not the proper forum to ask this question (it may be more JBoss Modules specific, but since I am using Wildfly exclusively, I wanted to check here first).

       

      I am cleaning up the Modules for my Wildfly 10 instance and I wanted to add all of my Spring dependencies as one big module and then import that into my project. This seems to work, but then I had the idea to be even more flexible. I wanted to break apart all of my modules into individual modules and then tie them together with a placeholder module. Is this possible? I am running into weird issues when attempting to do this.

       

      In other words, I would like to create a module directory, module.xml, etc. for each of the Spring jars (so you would have the module 'org.springframework.core', 'org.springframework.web', etc.) and then create a 'main' directory within the parent Spring directory and create the module 'org.springframework' which simply referenced the other Spring modules like so:

      module.xml

      --------------------------------------------------------------------------------------------------------------------------------------------------------------------

      <?xml version='1.0' encoding='UTF-8'?> 

      <module xmlns="urn:jboss:module:1.3" name="org.springframework"> 

       

        <dependencies>

       

          <module name="org.springframework.jms" slot="4.3.2.RELEASE"/>

          <module name="org.springframework.orm" slot="4.3.2.RELEASE"/>

          <module name="org.springframework.aop" slot="4.3.2.RELEASE"/>

          <module name="org.springframework.beans" slot="4.3.2.RELEASE"/>

          <module name="org.springframework.context" slot="4.3.2.RELEASE"/>

          <module name="org.springframework.core" slot="4.3.2.RELEASE"/>

          <module name="org.springframework.web" slot="4.3.2.RELEASE"/>

          <module name="org.springframework.oxm" slot="4.3.2.RELEASE"/>

           ....
           ....

        </dependencies>

       

      </module> 

       

      directory structure

      ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

      -base

        --org

           ---springframework

            ----aop

              -----4.3.2.RELEASE

                ------module.xml

                ------spring-aop-4.3.2.RELEASE.jar

            ----aspects

             -----4.3.2.RELEASE

               ------module.xml

               ------spring-aspects-4.3.2.RELEASE.jar

      ...

      ...

      ...

            ----main

              -----module.xml

       

      That way, in my Manifest, I would just have the one entry 'org.springframework' that referenced everything Spring related. This sort of works, but I get weird authentication issues (everything failing) and other errors that arise after the webapp loads successfully, making me think everything is working until you call the webapp.

       

      Any insight here? Is packaging together modules something that can be done? Am I just doing it wrong? Are we instead supposed to declare each individual module in our Manifest?

       

      Thanks for your time,

      Kevin.

        • 1. Re: Module of Modules?
          ctomc

          I think you need also something like this

           

          <module name="org.springframework.jms" slot="4.3.2.RELEASE"/>

                    <imports>

                      <include path="META-INF"/>

          ... any other paths...

                    </imports>

          </module>

          • 2. Re: Module of Modules?
            kmark

            You were correct Tomaz, I updated the module entries by chaging this:

            <module name="org.springframework.web" slot="4.3.2.RELEASE"/>

            to:

            <module name="org.springframework.web" slot="4.3.2.RELEASE" export="true" services="import"/>

            and all is well.

             

            However, as a follow-up question: from what I can tell, if the module is being brought in as a dependency, then you must declare the services to be imported but if the module is declared on its own (its own module dir, module.xml, etc.), then the services are imported implicitly? I was under the impression that you still had to declare the dependency within your pom.xml like so:

            org.springframework.web:4.3.2.RELEASE services

            as stated in the documentation here Class Loading in WildFly - WildFly 10 - Project Documentation Editor

             

            However, after some tests, it seems that the extra 'services' at the end does nothing. Is this correct? If a module is brought in as its own module and the jar is within the 'resources' block of the module.xml, you don't need to declare the services to be picked up? Only when you use the module as a dependency within some other module, do you need the 'services="import"'?