3 Replies Latest reply on Jan 16, 2013 9:02 AM by Paul Hinds

    How do you add a directory to the JBoss classpath

    Paul Hinds Newbie

      I need to add a directory /etc/whatever to the claspath so that code in EARs and WARs can use getResourceAsString("/some.xml").

       

      We have lots and lots of code and spring config that does this.

       

      Any ideas? the document on AS76 classloading does not indicate how this can be acheived.

       

      The method of adding the folder to the JBOSS_CLASSPATH seems to be been broken in AS7.

       

      Putting the config files in a Jar is not an acceptable option, the reason these properties are not hardcoded it they need to be editable.

        • 1. Re: How do you add a directory to the JBoss classpath
          Nicklas Karlsson Master

          I think you can have properties files outside the module jar according to https://community.jboss.org/wiki/HowToPutAnExternalFileInTheClasspath

          1 of 1 people found this helpful
          • 2. Re: How do you add a directory to the JBoss classpath
            Paul Hinds Newbie

            So answering my own question here based on that link and others.

             

            To get /etc/jboss on the classpath

             

            create /etc/jboss/module.xml

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

            <module xmlns="urn:jboss:module:1.1" name="config">

                <resources>

                    <resource-root path="."/>

                </resources>

            </module>

             

             

            Symlink as follows

             

            mkdir $JBOSS_HOME/modules/config

            ln -s /etc/jboss $JBOSS_HOME/modules/config/main

            (or for windows) mklink /D %JBOSS_HOME%\modules\config\main \etc\jboss

             

             

            Add

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

             

            to all standalone.xml files.

             

            Now you can add any config files to /etc/jboss and it appears on the classpath or any WAR deployed without having to edit the WAR.

            • 3. Re: How do you add a directory to the JBoss classpath
              Paul Hinds Newbie

              To restore server/default/conf functionality, using standalone as an example...

               

              create $JBOSS_HOME/standalone/conf/module.xml

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

              <module xmlns="urn:jboss:module:1.1" name="standalone.conf">

                  <resources>

                      <resource-root path="."/>

                  </resources>

              </module>

               

              symlink as follows

               

              mkdir -p $JBOSS_HOME/modules/standalone/conf

              ln -s $JBOSS_HOME/standalone/conf $JBOSS_HOME/modules/standalone/conf/main

              (or for windows)  mklink /D %JBOSS_HOME%\modules\standalone\conf\main %JBOSS_HOME%\standalone\conf

               

              Add

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

                <global-modules>

                  <module name="standalone.conf" />           

                </global-modules>

              </subsystem>

              to $JBOSS_HOME/standalone/standalone.xml

               

              Now you can add any files to standalone/conf and they appear on the servers classpath.

              2 of 2 people found this helpful