3 Replies Latest reply on Jan 25, 2007 1:03 PM by Peter Johnson

    Resource Hell

    mike rogers Newbie

      My company is using a third-party library (that's sadly absolutely necessary) whose main class takes as a constructor argument a String representing a configuration file on the filesystem. I'm implementing this library interface as a Service (SAR), and would really like to pack the configuration file into the SAR.

      How can I come up with an actual path and filename of the configuration file to pass to this convoluted library?

      ANY help or direction towards help would be greatly appreciated.


        • 1. Re: Resource Hell
          Elias Ross Master

          Do you know what call is being made, e.g. Class.loadResource() or something? If so, any file in the classpath (which includes the contents of all .jar files) should work.

          If not, you can get the path to JBoss as a System property.

          • 2. Re: Resource Hell
            mike rogers Newbie

            Thank you for your response.

            Unfortunately this library is much more insidious than that. It needs an actual file on the file system. I'm sure it's calling FileInputStream(filename) somewhere in the code, which only serves to anger me.

            I will have to pursue a different solution, since currently the config file is in the SAR's META-INF directory.

            Thanks again for your help.

            • 3. Re: Resource Hell
              Peter Johnson Master

              genman's second suggestion should work if you have an exploded sar:

              String server = System.getProperty("jboss.server.home.dir");
              StupidClass sc = new StupidClass(server + "deploy/myservice.sar/META-INF/some.config");

              I think there is even a way to access the file if you have a packaged sar, but I would have to dig for that.