-
1. Re: Finding an Application Property file
sbahal Aug 27, 2003 9:16 AM (in response to jebrick)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 Aug 27, 2003 9:32 AM (in response to jebrick)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
jonlee Aug 27, 2003 10:08 AM (in response to jebrick)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
mtb2ride Sep 18, 2003 4:26 PM (in response to jebrick)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