1 2 Previous Next 18 Replies Latest reply on Jan 24, 2015 12:12 PM by wdfink

    Confused by Help - How does one create a global module?

    sboscarine

      Hello All,

      I noticed in https://docs.jboss.org/author/display/AS7/Developer+Guide#DeveloperGuide-GlobalModules

       

      Global Modules

      It is also possible to set up global modules, that are accessible to all deployments. This is done by modifying the configuration file (standalone/domain.xml).

      For example, to add javassist to all deployments you can use the following XML:

      standalone.xml/domain.xml
      <subsystem xmlns="urn:jboss:domain:ee:1.0" >           

       

        <global-modules>

          <module name="org.javassist" slot="main" />           

        </global-modules>

      </subsystem>

      Note that the slot field is optional and defaults to main.

       

      I apologize if these are silly questions, but:

      • Where did "org.javassist" come from?  Where do we define a module name?
      • The help says both "(standalone/domain.xml)" and "standalone.xml/domain.xml" does that mean in standalone.xml OR domain.xml?...or when you say "standalone/domain.xml" is domain.xml in a folder named "standalone?"  (I assume standalone.xml OR domain.xml, but this help passage is extremely confusing)
      • What if I wanted to be able to access com.foo.Bar in a jar named myjar.jar?  How do I go from jar on my filesystem to being able to access com.foo.Bar from any war deployed to my container?
        • How do I deploy the jar?
        • How do I figure out what it's module name is?
        • ...then I assume I can simply edit the urn:jboss:domain:ee:1.0 section, right?

       

      Thanks!

      Steven

        • 1. Re: Confused by Help - How does one create a global module?
          sfcoy

          You probably want to have a look at JBoss Modules Home

          • 2. Re: Confused by Help - How does one create a global module?
            sboscarine

            Thanks Stephen, that was helpful. 

             

            Their documentation is horrible, but at least now I know to search for "JBoss Modules" and not "Global Modules JBoss AS 7." 

             

            For anyone else with this issue, the best I have seen so far is:

            http://www.javacodegeeks.com/2011/09/jboss-modules-example-modular-web.html

             

            Ilias Tsagklis did a better job documenting this anything I've seen so far.  So, unless I find a more automatic way of solving this problem, I have to do this manually which looks like it means:

            1. Creating a folder hierarchy in the server.
            2. Creating a modules.xml file manually and specifying it's dependencies.
            3. Copying the jars and modules.xml to that hierarchy.

             

            ...all to do something that was as simple as dumping a jar into a shared folder in previous releases of JBoss as well as most application servers.  Unless I find a simpler way to do this, we're going to have some annoyed and confused customers when we switch our app to EAP 6.

             

            I wonder if there's a maven plugin or AS7 hook to automatically deploy my jar as a module.

            • 3. Re: Confused by Help - How does one create a global module?
              erhard

              I woudn't just give the jar to the customer, but zip the whole module from the module-directory like

              cd $JBOSS_HOME/modules

              zip -r /Tmp/mylib.module path/to/mylib/main

              Then the customer just unzips the mylib.module from within $JBOSS_HOME/modules

              With a few lines of skript-code you can automate this and all other configuration (jboss-cli.sh --file). Right now I prepare some JBoss 7 training examples and all configurations can be created fully automated from a plain jboss-as-7.x.x.zip file without much effort. It really works great.

              • 4. Re: Confused by Help - How does one create a global module?
                mcanpuneet

                Hi

                 

                Creating JBOSS Global module is a two step process

                 

                1. Create folder inside "module\org\JBOSS\Sample_Module\Main". Here, org\JBOSS\Sample_Module is your global module. Place your jar file and its configuration file with it. Configuration file will be with name "module.xml" with contents

                • 5. Re: Confused by Help - How does one create a global module?
                  mcanpuneet

                  Hi

                   

                  Creating JBOSS Global module is a two step process

                   

                  1. Create folder inside "module\org\JBOSS\Sample_Module\Main". Here, org\JBOSS\Sample_Module is your global module. Place your jar file and its configuration file with it. Configuration file will be with name "module.xml" with contents

                   

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

                   

                  <module xmlns="urn:jboss:module:1.0" name="org.jboss.sample_module">

                      <dependencies>

                          <module name="javaee.api"/>

                      </dependencies>

                      <resources>

                          <resource-root path="jar_name.jar"/>

                          <!-- Insert resources here -->

                      </resources>

                  </module>

                   

                  2. Add this module name in JBOSS configuration. I am taking example of standalone.xml so entry has to be changed from

                   

                      <subsystem xmlns="urn:jboss:domain:ee:1.0/">

                   

                  to

                   

                      <subsystem xmlns="urn:jboss:domain:ee:1.0">
                          <global-modules>
                              <module name="sample_module" slot="main"/>
                          </global-modules>
                     

                  </subsystem>

                   

                  First step will create a Module and second step will load newly created module to make available for applicatons. One more thing, You have to restart JBOSS

                  • 6. Re: Confused by Help - How does one create a global module?
                    khushalsingh

                    Followed exact same above steps but getting:

                     

                    [Host Controller] 20:30:29,378 INFO  [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on 10.3.45.126:9999

                    [Host Controller] 20:30:30,397 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("add") failed - address: ([

                    [Host Controller]     ("profile" => "full-ha"),

                    [Host Controller]     ("subsystem" => "ee")

                    [Host Controller] ]) - failure description: "JBAS014803: Duplicate resource [

                    [Host Controller]     (\"profile\" => \"full-ha\"),

                    [Host Controller]     (\"subsystem\" => \"ee\")

                    [Host Controller] ]"

                    [Host Controller] 20:30:30,402 FATAL [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010933: Host Controller boot has failed in an unrecoverable manner; exiting. See previous messages for details.

                    [Host Controller] 20:30:30,422 INFO  [org.jboss.as] (MSC service thread 1-3) JBAS015950: JBoss EAP 6.0.0.GA (AS 7.1.2.Final-redhat-1) stopped in 16ms

                    20:30:30,744 INFO  [org.jboss.as.process.Host Controller.status] (reaper for Host Controller) JBAS012010: Process 'Host Controller' finished with an exit status of 99

                    20:30:30,746 INFO  [org.jboss.as.process] (Thread-8) JBAS012016: Shutting down process controller

                    20:30:30,747 INFO  [org.jboss.as.process] (Thread-8) JBAS012015: All processes finished; exiting

                     

                     

                    Any Idea?

                    • 7. Re: Confused by Help - How does one create a global module?
                      nickarls

                      Check out standalone-full-ha.xml (you're using this one, right?)

                       

                      Search for "urn:jboss:domain:ee" and make sure you don't have two of them

                       

                      (you might want to start a new thread if you have further problems)

                      • 8. Re: Confused by Help - How does one create a global module?
                        khushalsingh

                        Thanks Nicklas for a quick response, I am using domain.xml and adding global-modules entry under full-ha profile. Now I am getting different error and not able to start the domain controller.

                         

                        [Host Controller] 15:45:45,878 ERROR [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010932: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: JBAS014676: Failed to parse configuration

                        [Host Controller]       at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:141) [jboss-as-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                        [Host Controller]       at org.jboss.as.host.controller.DomainModelControllerService.boot(DomainModelControllerService.java:440) [jboss-as-host-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                        [Host Controller]       at org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:156) [jboss-as-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                        [Host Controller]       at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_05-icedtea]

                        [Host Controller] Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2536,17]

                        [Host Controller] Message: JBAS014789: Unexpected element '{urn:jboss:domain:ee:1.1}global-modules' encountered

                        [Host Controller]       at org.jboss.as.controller.parsing.ParseUtils.unexpectedElement(ParseUtils.java:85) [jboss-as-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                        [Host Controller]       at org.jboss.as.ee.subsystem.EESubsystemParser11.readElement(EESubsystemParser11.java:71)

                        [Host Controller]       at org.jboss.as.ee.subsystem.EESubsystemParser11.readElement(EESubsystemParser11.java:28)

                        [Host Controller]       at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final-redhat-1.jar:1.1.0.Final-redhat-1]

                        [Host Controller]       at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.handleAny(XMLExtendedStreamReaderImpl.java:69) [staxmapper-1.1.0.Final-redhat-1.jar:1.1.0.Final-redhat-1]

                        [Host Controller]       at org.jboss.as.host.controller.parsing.DomainXml.parseProfiles(DomainXml.java:735) [jboss-as-host-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                        [Host Controller]       at org.jboss.as.host.controller.parsing.DomainXml.readDomainElement1_3(DomainXml.java:340) [jboss-as-host-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                        [Host Controller]       at org.jboss.as.host.controller.parsing.DomainXml.readElement(DomainXml.java:130) [jboss-as-host-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                        [Host Controller]       at org.jboss.as.host.controller.parsing.DomainXml.readElement(DomainXml.java:105) [jboss-as-host-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                        [Host Controller]       at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final-redhat-1.jar:1.1.0.Final-redhat-1]

                        [Host Controller]       at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final-redhat-1.jar:1.1.0.Final-redhat-1]

                        [Host Controller]       at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:133) [jboss-as-controller-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                        [Host Controller]       ... 3 more

                        [Host Controller]

                        [Host Controller] 15:45:45,891 FATAL [org.jboss.as.host.controller] (Controller Boot Thread) JBAS010933: Host Controller boot has failed in an unrecoverable manner; exiting. See previous messages for details.

                         

                         

                         

                        Here is what I have:

                         

                        $ pwd

                        /opt/web/jboss-eap-6.0/modules/com/jboss/jbsec/main

                         

                        $ ls -tlr

                        total 236

                        -rw-r--r-- 1 jbsvc jbadm 234035 Nov 29 13:04 jbossweb-service.jar

                        -rw-r--r-- 1 jbsvc jbadm    249 Nov 29 15:02 module.xml

                         

                         

                        $ more module.xml

                         

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

                        <module xmlns="urn:jboss:module:1.1" name="com.jboss.jbsec">

                                <dependencies>

                                        <module name="javaee.api"/>

                                </dependencies>

                                <resources>

                                        <resource-root path="jbossweb-service.jar"/>

                                </resources>

                        </module>

                         

                        $

                         

                         

                        This I added in domain.xml under full-ha profile stanza:

                         

                                    <subsystem xmlns="urn:jboss:domain:ee:1.1">

                                       <global-modules>

                                          <module name="jbsec" slot="main"/>

                                       </global-modules>

                                        <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

                                        <global-modules/>

                                        <spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>

                                        <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>

                                    </subsystem>

                         

                         

                        I tried creating module under com/jboss/main instead of com/jboss/jbsec/main

                         

                        and added following in the domain.xml, but that also did not work.

                         

                                       <global-modules>

                                          <module name="jboss" slot="main"/>

                                       </global-modules>

                        • 9. Re: Confused by Help - How does one create a global module?
                          nickarls

                          Take out the second <global-modules/>, not sure the xsd allows for this. And in any case the ref should be com.jboss.jbsec

                          • 10. Re: Confused by Help - How does one create a global module?
                            khushalsingh

                            Tried this but started getting problem in server startup:

                             

                            $ pwd

                            /opt/web/jboss-eap-6.0/modules/com/jboss/jbsec/main

                             

                            $ ls -tlr

                            total 236

                            -rw-r--r-- 1 jbsvc jbadm 234035 Nov 29 13:04 jbossweb-service.jar

                            -rw-r--r-- 1 jbsvc jbadm    249 Nov 29 15:02 module.xml

                             

                            $ more domain.xml

                             

                                        <subsystem xmlns="urn:jboss:domain:ee:1.1">

                                        <global-modules>

                                            <module name="com.jboss.jbsec" slot="main"/>

                                        </global-modules>

                                            <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

                                            <spec-descriptor-property-replacement>false</spec-descriptor-property-replacement>

                                            <jboss-descriptor-property-replacement>true</jboss-descriptor-property-replacement>

                                        </subsystem>

                             

                            Error in server.log (log is full of these errors). server comes up fine If I take out global-modules entry from the domain.xml.

                             

                            [Server:wms] 16:23:07,895 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.module.service."deployment.ojdbc6.jar".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.ojdbc6.jar".main: JBAS018759: Failed to load module: deployment.ojdbc6.jar:main

                            [Server:wms]    at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:92) [jboss-as-server-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                            [Server:wms]    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]

                            [Server:wms]    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_05-icedtea]

                            [Server:wms]    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_05-icedtea]

                            [Server:wms]    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_05-icedtea]

                            [Server:wms] Caused by: org.jboss.modules.ModuleNotFoundException: Module com.jboss.jbsec:main is not found in local module loader @707e4019 (roots: /opt/web/jboss-eap-6.0/modules)

                            [Server:wms]    at org.jboss.modules.LocalModuleLoader.findModule(LocalModuleLoader.java:126) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:275) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:222) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.LocalModuleLoader.preloadModule(LocalModuleLoader.java:94) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.Module.addPaths(Module.java:851) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.Module.link(Module.java:1206) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.Module.relinkIfNecessary(Module.java:1235) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:208) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:71) [jboss-as-server-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                            [Server:wms]    ... 5 more

                            [Server:wms]

                            [Server:wms] 16:23:07,915 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.module.service."deployment.ifxjdbc.jar".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.ifxjdbc.jar".main: JBAS018759: Failed to load module: deployment.ifxjdbc.jar:main

                            [Server:wms]    at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:92) [jboss-as-server-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                            [Server:wms]    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]

                            [Server:wms]    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_05-icedtea]

                            [Server:wms]    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_05-icedtea]

                            [Server:wms]    at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_05-icedtea]

                            [Server:wms] Caused by: org.jboss.modules.ModuleNotFoundException: Module com.jboss.jbsec:main is not found in local module loader @707e4019 (roots: /opt/web/jboss-eap-6.0/modules)

                            [Server:wms]    at org.jboss.modules.LocalModuleLoader.findModule(LocalModuleLoader.java:126) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:275) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:222) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.LocalModuleLoader.preloadModule(LocalModuleLoader.java:94) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.Module.addPaths(Module.java:851) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.Module.link(Module.java:1206) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.Module.relinkIfNecessary(Module.java:1235) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:208) [jboss-modules.jar:1.1.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:71) [jboss-as-server-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                            [Server:wms]    ... 5 more

                            [Server:wms]

                            [Server:wms] 16:23:08,001 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.module.service."deployment.jt400.jar".main: org.jboss.msc.service.StartException in service jboss.module.service."deployment.jt400.jar".main: JBAS018759: Failed to load module: deployment.jt400.jar:main

                            [Server:wms]    at org.jboss.as.server.moduleservice.ModuleLoadService.start(ModuleLoadService.java:92) [jboss-as-server-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]

                            [Server:wms]    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]

                            [Server:wms]    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-1.jar:1.0.2.GA-redha

                            • 11. Re: Confused by Help - How does one create a global module?
                              nickarls

                              Have you tried without the explicit main slot?

                              • 12. Re: Confused by Help - How does one create a global module?
                                khushalsingh

                                Thanks Nicklas, Problem got resolved after adding the module in all the host controllers.

                                • 13. Re: Confused by Help - How does one create a global module?
                                  sboscarine

                                  If it helps anyone in the thread, I found a way to do create a global module via CLI:

                                   

                                  module add --name=com.mydomain.placeholder --resources=placeholder\target\placeholder-6.6.6-SNAPSHOT.jar
                                  /subsystem=ee:write-attribute(name="global-modules",value=[{"name" => "com.mydomain.placeholder","slot" => "main"}])
                                  

                                   

                                  That's much less painful than what I first did, with creating folders and editing XML

                                  • 14. Re: Confused by Help - How does one create a global module?
                                    a_oid

                                    Hi Togehter,

                                     

                                     

                                    module add --name=com.mydomain.placeholder --resources=placeholder\target\placeholder-6.6.6-SNAPSHOT.jar
                                    /subsystem=ee:write-attribute(name="global-modules",value=[{"name" => "com.mydomain.placeholder","slot" => "main"}])

                                     

                                    Does this command distribute the resources (placeholder\target\placeholder-6.6.6-SNAPSHOT.jar here) to the host in domain mode?...

                                    if not is it impossible to use this command or do i just have to add the jar files after running that?...

                                     

                                     

                                    i hope i can try this as fast as possible...i will add the results.

                                    1 2 Previous Next