0

I have a property file which is being called as a resource bundle from one java class and this java classes are wrapped as one JAR file and being included in another java application. From the second java application, I need to call this property file. While doing that, I am getting exception

"Caused by: java.util.MissingResourceException: Can't find bundle for base name DSPDB, locale en_US"

I am not sure where to include that .property file so that it is visible at runtime.

Please help.

Valijon
  • 12,667
  • 4
  • 34
  • 67
Prakruti Pathik
  • 392
  • 4
  • 17
  • could you post the structure of your jar file? Where is the prop file right now? – Emre Türkiş Dec 02 '15 at 07:43
  • do you mean `.properties`? Normally, it should be stored in `src/main/resources`. Once you package you JAR, it will be moved inside that JAR in correct place (normally, root directory) – Valijon Dec 02 '15 at 07:44
  • Hi @Valijion, is it not possible to place the .property file outside the jar file?I am deploying this jar in jboss 7. I want to place it somewhere on the server so that it is easy to configure. – Prakruti Pathik Dec 02 '15 at 08:30
  • 1
    Yes you can. You need to implement this code: `System.getProperty("some_key", null);` to check where some_key is defined by environment or execution parameter. So, later, you can execute: `java -jar your_jar.jar -Dsome_key=path/to/properties` – Valijon Dec 02 '15 at 08:47
  • can you elaborate this? I have already tried placing the property file in the configuration folder of the server and tried loading it. But it doesnt seem to be working. – Prakruti Pathik Dec 02 '15 at 08:54
  • Please find the code modified: private final static String BUNDLE_NAME = "DSPDB"; private final static ResourceBundle RESOURCE_BUNDLE = ResourceBundle .getBundle(System.getProperty(DSP_PROPERTIES_HOME) + File.separator + BUNDLE_NAME); – Prakruti Pathik Dec 02 '15 at 08:55
  • @Valijon can you elaborate this? I have already tried placing the property file in the configuration folder of the server and tried loading it. But it doesnt seem to be working. Please find the code modified: private final static String BUNDLE_NAME = "DSPDB"; private final static ResourceBundle RESOURCE_BUNDLE = ResourceBundle .getBundle(System.getProperty(DSP_PROPERTIES_HOME) + File.separator + BUNDLE_NAME); – Prakruti Pathik Dec 02 '15 at 09:29
  • Try to get you path from `System.getProperty(key, default)` and implement by this recommendation [http://stackoverflow.com/a/1172467/3710490](http://stackoverflow.com/a/1172467/3710490) – Valijon Dec 02 '15 at 11:37
  • I have still not resolved this. can any help? – Prakruti Pathik Dec 03 '15 at 08:54

1 Answers1

0

I followed the following link thought it will be helpful:

https://developer.jboss.org/message/615618

Basic idea is to put the property file in a config path and make the path available on class path of JBOSS server.

Prakruti Pathik
  • 392
  • 4
  • 17