1 Reply Latest reply on Feb 10, 2005 1:24 PM by jimm

    Loading resources that are not part of the J2EE application

    karin k Newbie

      Hi,

      I try to load property files and other resources from a directory
      that is not part of my J2EE application. Resources are not packaged
      inside a jar file

      I did the following configuration:
      Deployment is made via JMX by means of addUrl of the DeploymentScanner.
      The deployed directory looks like this

      * jboss-service.xml
      * war - file
      


      The content of the jboss-service.xml looks like this
      <server>
       <loader-repository>com.winterthur.jackpot.karin:loader=sample.ear
       <loader-repository-config>java2ParentDelegation=false
       </loader-repository-config>
       </loader-repository>
      
       <!-- this is just an example do not care that which library it is -->
       <classpath codebase="file:/C:/common/" archives="mycommonlib.jar"/>
       <classpath codebase="file:/C:/commonresources/" archives="*"/>
      </server>
      


      I defined the same loader repository in the jboss-web.xml of the War file.

      In the servlet I try to load a resource that is located inside the directory
      commonresources
      URL url=Thread.currentThread().getContextClassLoader().getResource("myresource.txt");
      


      In the server.log file the following is logged:
      2005-02-08 16:58:05,776 DEBUG [org.jboss.mx.loading.RepositoryClassLoader] Added url: file:/C:/commonresources/myresource.txt, to ucl: org.jboss.mx.loading.UnifiedClassLoader3@7c7894{ url=file:/C:/eplatform/jboss/4.0/server/eplatform/tmp/deploy/tmp16962jboss-service.xml ,addedOrder=11}
      


      The file myresource.txt cannot be loaded.
      But it can be loaded if I place the file myresource.txt in
      a Jar file and put it in the directory C:/commonresources/.
      It can be loaded as well when I create a sub-directory in the folder C:/commonresources/mydirectory
      (e.g. C:/commonresources/mydirectory) and put my file there.
      Is this really the way to do it? Is something wrong with this configuration.
      Thanks and regards
      Karin

        • 1. Re: Loading resources that are not part of the J2EE applicat
          jimm Newbie

          The SARDeployer uses the archives="*" to mean that all of the archives (compressed and exploded) in the codebase directory should be added to the classpath.

          If you want the codebase directory added to the classpath then leave out the archives attribute.

          If the codebase specified url contains resources and not archives then do not use the archives attribute.

          In your example where the myresource.txt is in C:/commonresources this would look like:

          <classpath codebase="file:/C:/commonresources/" />