5 Replies Latest reply on Apr 23, 2013 2:59 PM by riskyseven

    Jboss7 classloading

    jboss_dev a Newbie

      Hello All,

       

      I know there are many links on the forum discussing the same but I just wanted some imput from the Jboss community.

       

      We have all the jars required by our application in a separate directory say - C:\Program Files (x86)/application/server/lib

      and the config files in C:\Program Files (x86)/application/server/conf. We used to add C:\Program Files (x86)/application/server/lib and C:\Program Files (x86)/application/server/conf to the server classpath and this used to work on JBOSS-5.We deploy our application on multiple platforms(Websphere,Tomcat,Jboss5 etc) and keeping the application jars and config files seperate from the server files has worked well so far.

      Now we are upgrading to JBOSS 7 and I cannot add the above folders to jboss classpath.I need to now move all the required jars into seperate modules under JBOSS_HOME\modules and then 

      in jboss-deployment-structure.xml define the dependencies for Jboss7.This will mean having the jars and config files in 2 separate places.

       

      I found this link - https://community.jboss.org/message/730142 which is about adding another directory to the JBOSS_MODULEPATH.

      I did the same.Created an environment variable JBOSS_MODULEPATH=C:\jboss-as-7.1.1.Final\modules:C:\Program Files (x86)\application\server\lib

      But on starting Jboss get the below error -

       

        JAVA_OPTS: -XX:+TieredCompilation -Dprogram.name=standalone.bat -Xrs -Xms256M -Xmx1024M -XX:MaxPermSize=256M

      ===============================================================================

      org.jboss.modules.ModuleNotFoundException: Module org.jboss.as.standalone:main is not found in local module loader @10f11b8 (roots: C:\jboss-as-7.1.1.Final\modules:C:\Program Files (x86)\application\server\lib)
      at org.jboss.modules.LocalModuleLoader.findModule(LocalModuleLoader.java:126)
      at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:275)
      at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:222)
      at org.jboss.modules.LocalModuleLoader.preloadModule(LocalModuleLoader.java:94)
      at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:204)
      at org.jboss.modules.Main.main(Main.java:262)

       

      I even tried creating a module for my config files as - modules\com\application\configuration\main and in the module.xml

      <module xmlns="urn:jboss:module:1.1" name="com.mycompany.settings">
          <resources>
              <resource-root path="C:\Program Files (x86)/application/server/conf"/>  --> gave an absolute path.
          </resources>
      </module>

      I did not add my config files to the folder but I expected them to be picked from the location provided but that does not work.

      Is there no way of adding an external folder to Jboss 7 classpath ? Any help would be much appreciated.

      Thank you.

        • 1. Re: Jboss7 classloading
          Nicklas Karlsson Master

          I think the ; is the separator char to use(?)

          • 2. Re: Jboss7 classloading
            jboss_dev a Newbie

            Thank you.We figured it out and got Jboss looking at another directory in addition to the 'modules' folder by updating the module path in standalone.bat as -->  -mp "%JBOSS_MODULEPATH%";"C:\Program Files (x86)\application\server\lib";

            Put all our jars in a 'main' folder in C:\Program Files (x86)\application\server\lib as Jboss7 looks for a 'main' folder.Created a module.xml listing all the jars in lib\main.It would be good if we could avoid mentioning each jar but so far haven't got that working.Then defined a global module in standalone.xml as

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

            These are the links that helped us in solving the issue - https://community.jboss.org/message/615774

            https://community.jboss.org/message/730142

            https://community.jboss.org/wiki/HowToPutAnExternalFileInTheClasspath

            Hopefully this might be helpful for others.

            • 3. Re: Jboss7 classloading
              Nicklas Karlsson Master

              I can almost hear the JBoss Modules developers scream in pain

              • 4. Re: Jboss7 classloading
                jaikiran pai Master

                I think the global-modules configuration in the EE subsystem should never have been exposed to the users. It's already been abused a lot and isn't really a solution.

                • 5. Re: Jboss7 classloading
                  riskyseven Newbie

                  jboss_dev a: Thank you!  I am in a very similar situation and your solution was a huge help.  I boiled it down a bit for my situation...maybe it will help someone else.

                   

                  JBoss7.1.1

                   

                  $JBOSS_HOME/standalone/configuration/standalone.xml:


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

                  <global-modules>

                  <module name="blah" slot="ver1"/>

                  </global-modules>

                  </subsystem>

                   

                  $JBOSS_HOME/modules/blah/ver1:

                  <module xmlns="urn:jboss:module:1.0" name="blah" slot="ver1">

                      <dependencies>

                          <module name="javaee.api"/>

                      </dependencies>

                      <resources>

                          <resource-root path="../../../../../home/me/classes"/>

                          <resource-root path="../../../../../home/me/lib/ant-contrib.jar"/>

                  ...resource-root entry for each jar file.  I tried absolute paths as the docs indicate this should work...but sadly it does not.  Stuck with relative path hack.

                      </resources>

                  </module>

                   

                  I did not modify the -mp  argument.

                   

                  Nicklas/jaikiran: Obviously, this *is* a solution.  It works.  'The JBoss way' changes every release, and some of us have to remain app server agnostic due to business/market concerns regardless.  Rather than criticize the community for contributing a solution, perhaps you could contribute your own?

                   

                  Cheers.