Does anybody know how to reference a directory packaged within an EAR file other than using a System property to manualy specify the absolute location of the installed EAR. In my code, I want to load a properties file in a config directory packaged within my WAR. If I do a 'new File("config/config.props")' the code looks in the bin directory of my appserver! I cannot seem to reference file resources within my EAR. Please Help Cheers, John
An option that is open to you is to load such resources with the ClassLoader, for example, using getClass().getResource("/myResources.properties"). This means that you can then simply include resources inside your JAR files. Of course, if you are loading resources from a webapp within an EAR file, you can also use getServletContext().getResource() if your resources are underneath the WEB-INF directory of your web application. Using a system property to directly reference the deployed location of an EAR file is not the best thing to do, simply because the app servers are free to copy and unextract the contents into a directory on deployment. Hope that helps Simon
Joined: Apr 18, 2002
Simon, your a star ! I'd tried the class.getResource("") method before but it kept giving me the runtime of the appserver, but the getServletContext().getResource() works fine. Many thanks !