Dynamically Get Properties Filename in EJB Jar (deployed in ear)?

You can use environment entries and inject them using Resource to achieve what you want.

You can use environment entries and inject them using @Resource to achieve what you want. Take a look at this OpenEJB example. However, if you say something like: The properties file won't be included in either the jar or ear but is located on the server outside of the app server.

I doesn't sound good for an enterprise application. You should not depend on resources outside of the container and not make any assumptions about resources which you (container) don't control. Operations on files are also discouraged (if not forbidden - don't remember exactly).

Thanks for the link; I'll look into it. The reason the properties files are not included in the jar/ear is because they are different depending on which sytem we are deploying to (e.g. Lab, prod). The reason to use properties files in the first place is because they can change.

Which version of the properties do you include, lab or prod? And what if you accidentally overwrite the prod properties with lab because of a redeploy of the app? – sdoca Nov 22 at 22:24 @sdoca just consider it as "you've been warned" post :-) By the way - does your lab/prod properties are changed by some other process than your application and that's why you cannot include it in your application?

– Piotr Nowicki Nov 22 at 22:28 So, based on the link you provided, I got it to work. Thanks! I had a Singleton class in my jar already that contained the constants for the different property keys used, so that was a natural fit to put the @Resource for the file path.

I created method to load the properties and annotated it with the @PostConstruct annotation and annotated the class with the @Startup annotation to ensure it was loaded. – sdoca Nov 22 at 23:10 Great, that sounds very reasonable :-) – Piotr Nowicki Nov 22 at 23:11 My application reads the properties file, it doesn't set them. Consider myself warned.

Although, I've used external properties files for years and years for my web/war applications without issue, so I think I'm safe. :) – sdoca Nov 22 at 23:12.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions