4 Replies Latest reply on Sep 18, 2003 4:26 PM by Steve Dodge

    Finding an Application Property file

    jebrick Newbie

      I'm porting a J2EE App to JBoss and have run into a configuration problem. The .EAR file contains a .property file that the App looks for at startup. On the two other app servers that this App has been deployed on I could just set a directory location that the file would deploy to but I can't seem to find that in JBoss.

      I will not change the .EAR file if i can help it. This runs on two other servers as is. The more work/changes I have to do the less likely it will be that I can get the powers-that-be to allow JBoss as an alternative.

      Should/Can I set up a conf file to tell JBoss where to deploy the App so I can tell where the .property file is?

      Is there a setting/mbean to set up a deployment directory.

      Anysuggestion as to solving this would be very helpfull.

      thanks

        • 1. Re: Finding an Application Property file
          sbahal Newbie

          The way I do it is in JBoss:
          InputStream stream = ( this).getClass().getClassLoader().getResourceAsStream(propFile);

          I put the propFile in the conf directory.
          HTH
          Sanjay

          • 2. Re: Finding an Application Property file
            jebrick Newbie

            It also appears that I could use the SystemPropertiesService to set the location but it does not accually answer the problem.

            This means that I must do different deploys. One for the .EAR and one for the property file. I was hopping that I could set a conf file to tell it where to deploy but it does not seem to be the case as JBoss doers not really deploy the files other than in a tmp directory.

            • 3. Re: Finding an Application Property file
              Jon Barnett Master

              J2EE does not mandate that a deployment must manifest the physical files.

              For example the deployment may defined as a network resource, perhaps on a remote file system or as stored on a database as a stored BLOB. You would probably find that your application would not work in a production SilverStream server as the deployment packages are normally stored in the database - no physical files are ever produced and hence no "real path" for any files packaged in the deployment.

              If you look at the Servlet spec for getRealPath, you will find that it can acceptably return null if no real path exists, which may happen if there are no physical artefacts from the deployment - no local files and directories for the full deployment.

              You could deploy the application as an unpacked distribution in JBoss. This results in a full manifestation of the files and file structures. However, for complete portability for any application server, you would normally use the getResourceAsStream as this is guaranteed AFAIK to obtain a handle to a resource in a deployment.

              SUN JDC and JavaGuru discuss this topic in greater depth.

              • 4. Re: Finding an Application Property file
                Steve Dodge Newbie

                I'm loading xml files and using the commons digester to build objects based on the xml files. In this case I was successful in using getResourceAsStream("/WEB-INF/menus/roaming_menu.xml")
                to retrieve a valid InputStream and pass it into the digester for parsing.

                So, yes, getResourceAsStream() works.

                Thanks
                Steve