7 Replies Latest reply on Oct 10, 2012 7:22 AM by crazycradd

    adding local file to classpath

    crazycradd

      I have a few apps I'm trying to port to as7

       

      In 4.2.3the /conf directory is part of the classpath, I have a few post deployment config files that are written to this directory.

       

      I have added a a jboss-deployment-structure.xml file to my webinf directory to try and add a local directory to my classpath but this does not seem to work. Is it possible to add a local directory to the classpath in as7 or shalll I look to alter my code to address this problem. PLacing the file in the web-inf/classes is not realy an option since this will be overwritten with every deployment.

       

      <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">

           <deployment>

                <resources>

                     <resource-root path="/conf" />

                </resources>

           </deployment>

      </jboss-deployment-structure>

        • 1. Re: adding local file to classpath
          bonigv

          I am working on a similar problem with my product.  A bunch of configuration files are expected to be in the classpath.  Currently it seems there is no straight solution.  This is a problem.

          • 2. Re: adding local file to classpath
            sony2006

            Hi

             

            I am also facing this problem. Found any solution?

             

            Thanks

            Sony

            • 3. Re: adding local file to classpath
              bonigv

              I worked out a solution for this.  Still looks a bit hacky but works.

               

              Step 1 :

              Create a module out of the conf folder.  So I created JBOSS_HOME/modules/com/myorg/myapp/1.0/conf

               

              Step 2:

              Copy the original contents of conf (those you wanted in classpath) into this folder.

               

              Step 3:

              Created JBOSS_HOME/modules/com/myorg/myapp/1.0/module.xml like below

               

              <module xmlns="urn:jboss:module:1.1" name="com.myorg.myapp" slot="1.0">

                    <resources>

                      <resource-root path="conf"/>

                      <!-- Insert resources here -->

                  </resources>

              </module>

               

              Step 4:

              modified my jboss-deployment-structure.xml to add a dependency to my conf module

                   

              <dependencies>

                    <module name="org.myorg.myapp" slot="1.0"/>

              </dependencies>

               

              That is all.  The resources were discovered on the classpath.  This solution works for us since the 'conf' remains as a folder and is tunable.

              1 of 1 people found this helpful
              • 4. Re: adding local file to classpath
                sony2006

                Thanks a lot, That worked.

                But is there any way possible to specify an external folder ( not in the modules directory ) as the resource-root path ?

                 

                Thanks

                Sony

                • 5. Re: adding local file to classpath
                  crazycradd

                  I did something similar rather than creating a module I had already deployed an exploded war as the root context of the container.

                   

                  So I placed the config files in the classes directory of the exploded war I then added the following to jboss-deployment-structure.xml

                   

                          <dependencies>

                              <module name="deployment.abs.war" />

                          </dependencies>

                   

                  It would be nice to see if there is a solution to this problem rather then the work arounds we have come up with.

                  • 6. Re: adding local file to classpath
                    snicktc

                    Is there any progress on this issue ?

                    • 7. Re: adding local file to classpath
                      crazycradd

                      classpath seems to be tied to the solutions above alternativly add a system property of a dir to search for your local file